-
Notifications
You must be signed in to change notification settings - Fork 21
Compiler crash with AssertionError "mixed in lazy value .. from class .. is not param?!" #10223
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-10223?orig=1 |
@adriaanm said: What's the purpose of the abstract method x? |
@adriaanm said: |
The fragment of code (current for (sym <- clazz.info.decls ; if sym hasFlag MIXEDIN) {
// if current class is a trait, add an abstract method for accessor `sym`
// ditto for a super accessor (will get an RHS in completeSuperAccessor)
if (clazz.isTrait || sym.isSuperAccessor) addDefDef(sym)
// implement methods mixed in from a supertrait (the symbols were created by mixinTraitMembers)
else if (sym.hasFlag(ACCESSOR) && !sym.hasFlag(DEFERRED)) {
assert(sym hasFlag (PARAMACCESSOR), s"mixed in $sym from $clazz is not param?!?")
// add accessor definitions
addDefDef(sym, accessorBody(sym))
} |
A slightly reduced example, using existing types from the base library: object BrokenLit {
trait Test { lazy val x: String = ""}
abstract class Test2 extends Test { override def x: Any }
}
Could you clarify why this should compile? The two key aspects of this example are:
|
I've stumbled across this via a different route:
It is given that the code shouldn't compile, but it slays the compiler instead of producing a nice error with
|
still reproduces in 2.13.11. Scala 3.3.1-RC5:
|
|
to summarize: @melezov's version is okay now, but the original report and Diego's version both still crash |
I was taking a look. Scala 3 benefits from treating the abstract member overriding the concrete member, so it errors correctly in refchecks. In Scala 2, concrete member has precedence over abstract member, but Refchecks has a supplementary rule that still requires a concrete implementation in a subclass. So that clarifies why it should compile; Jasper's comment on the open dotty ticket is an example of the second rule. The wider method is bridged in erasure. But a concrete subclass is required to supply an implementation. |
The code:
Causes the compiler to assertion fail:
The text was updated successfully, but these errors were encountered: