-
Notifications
You must be signed in to change notification settings - Fork 1.1k
AssertionError in dotty.tools.dotc.transform.ResolveSuper #14415
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
The abstract override check is skipped because of the use of inLinearizationOrder in: More precisely, when we check as seen from class X if method m in D is a valid override of method m in C, the check is skipped because C is a parent of D, but it turns out that for abstract override checks this isn't enough: the linearization order of D is |
I think the problem is not the check triggered by the definition of class
The difference to Scala2 is, that the Scala3 compiler does not report an error on the definition of method |
Not sure what you mean, Scala 2 does not report an error if I try to typecheck D and its parent classes but not X: trait A {
def m(a:Int): Int
}
trait B extends A {
override def m(a:Int): Int = { return a; }
}
trait C extends A {
abstract override def m(a:Int):Int = { return super.m(a); }
}
trait D extends B with C {
override def m(a:Int):Int = { return super.m(a); }
} The error you mention is only reported in X, because it's only when clazz=X, other=C.m that |
Sorry for the confusion. You are right. Scala 2 also only reports an error on the definition on Scala 2 (2.13.8) shows the following behavior:
Scala 3 (3.1.1) shows the following behavior:
|
@smarter Your analysis is spot on. |
Compiler version
Minimized code and output
I executed the following lines in the Scala REPL:
and with entering the last line I see the following stack trace (and the shell exits).
Click to expand!
Expectation
Well, the definition of class
X
is not correct and therefore I expected an error message. The linearization ofX
isX D E B C A
i.e. classC
is not mixed in correctly as methodC.m
is declaredabstract
(i.e. needs to be mixed in in such a way that a concrete implementation follows classC
in the linearization). The problem seems to be the definition of methodD.m
which should have been declared asabstract override
.Scala 2 reports an error on definition of method
D.m
:If method
D.m
were declared asabstract override
, then the Scala compiler would report the following error on creation of classX
without crashing:The text was updated successfully, but these errors were encountered: