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
compiler crash with trait inside method (part I: add implementation restriction) #6231
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6231?orig=1 |
@retronym said: object Bug {
def bar(ev: Any) {
trait X {
def qux = { () => ev }
}
}
}
|
@retronym said: case Select(qual, name) if sym.owner.isImplClass && !isStaticOnly(sym) =>
assert(!sym.isMethod, "no method allowed here: %s%s %s".format(sym, sym.isImplOnly, flagsToString(sym.flags)))
// refer to fields in some implementation class via an abstract
// getter in the interface.
val iface = toInterface(sym.owner.tpe).typeSymbol
val getter = sym getter iface orElse abort("No getter for " + sym + " in " + iface)
typedPos(tree.pos)((qual DOT getter)())
This comment seems relevant: /** If this symbol is an implementation class, its interface, otherwise the symbol itself
* The method follows two strategies to determine the interface.
* - during or after erasure, it takes the last parent of the implementation class
* (which is always the interface, by convention)
* - before erasure, it looks up the interface name in the scope of the owner of the class.
* This only works for implementation classes owned by other classes or traits.
* !!! Why?
*/
def toInterface: Symbol = this |
@gkossakowski said: |
@retronym said: |
@retronym said: |
Sorry the summary isn't great; this crashed the compiler, it's as minimized as I could get it from my original encounter.
causes a compiler crash under both 2.9.2 and 2.10.0-M6. Uncommenting the two commented lines allows us to work around this issue for now.
The output from M6 is:
The text was updated successfully, but these errors were encountered: