Skip to content

tpd.ModuleDef fails if owner isn't a class #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DarkDimius opened this issue Mar 11, 2014 · 2 comments
Closed

tpd.ModuleDef fails if owner isn't a class #56

DarkDimius opened this issue Mar 11, 2014 · 2 comments

Comments

@DarkDimius
Copy link
Contributor

If one tries to construct such class by hand using tpd.*

class A{
  def p() = {
    object B {val d = 1};
    B.d
  }
}

During creation of object B, Symbol.newModuleSymbol will try to get TermRef(owner.thisType, name), with will obviously lead to prefix being NoPrefix(just like it is in typeCheker generated symbols for such code) which in turn will cause this assertion to fail: https://github.com/lampepfl/dotty/blob/d827b0180b05e7461856f668c3c4ca0ea6ed5d62/src/dotty/tools/dotc/core/Types.scala#L1186

@DarkDimius
Copy link
Contributor Author

odersky added a commit to odersky/dotty that referenced this issue Mar 12, 2014
newModuleSymbol failed before if owner was a term. Now we generate a symbolic termRef as a sourceModule
link which works also term owner, where owner.thisType gives NoProfix.
odersky added a commit to odersky/dotty that referenced this issue Mar 12, 2014
Needs new TypeRef creation method that works for NoPrefix and at the same time
does not need a denotation. This is provided by method TermRef.withNakedSymbol.
DarkDimius added a commit to DarkDimius/dotty that referenced this issue Mar 12, 2014
odersky added a commit to odersky/dotty that referenced this issue Mar 12, 2014
Need a fix analogous to what was done in newModuleSymbol to determine the source module of
a module class.
DarkDimius added a commit to DarkDimius/dotty that referenced this issue Mar 12, 2014
DarkDimius pushed a commit to DarkDimius/dotty that referenced this issue Mar 12, 2014
Needs new TypeRef creation method that works for NoPrefix and at the same time
does not need a denotation. This is provided by method TermRef.withNakedSymbol.
DarkDimius pushed a commit to DarkDimius/dotty that referenced this issue Mar 12, 2014
Needs new TypeRef creation method that works for NoPrefix and at the same time
does not need a denotation. This is provided by method TermRef.withNakedSymbol.
@odersky
Copy link
Contributor

odersky commented Mar 16, 2014

Fixed in #64

@odersky odersky closed this as completed Mar 16, 2014
DarkDimius pushed a commit to DarkDimius/dotty that referenced this issue Mar 18, 2014
Needs new TypeRef creation method that works for NoPrefix and at the same time
does not need a denotation. This is provided by method TermRef.withNakedSymbol.
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this issue Mar 19, 2025
Backport "Fix scala#9879: allow top-level opaque type definitions in REPL" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants