-
Notifications
You must be signed in to change notification settings - Fork 21
"VerifyError: Bad invokespecial" when explicitly super call an abstract method #8693
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-8693?orig=1 |
This "works" in version 2.12.8, and even as early as in Scala 2.12.0. By "works" I mean that there is no longer a compiler crash, and the compiler accepts the program and succeeds. However, I am not sure if that is the correct expected behaviour. In the example, class Does the specification allow for a sub-trait to include an abstract declaration that shadows a concrete definition from a super-class? |
I would say that it should not compile and be flagged with an error. However, it should be possible that a sub-trait shadows an inherited implementation with an abstract one. This is comparable to the case where a method from the base class is overridden in a sub-class with an abstract method:
This is used e.g. in the Java-Library in class However, if the above given class
leads to the compiler error
I expect a similar error message at the definition of method print in trait
As you wrote, the above code can be compiled with Scala 2.12.8, but if an instance of
Actually, I expected the same behavior if trait
However, with the second definition of Summary:
|
I am not an expert here, but I would not expect or want it to compile, and honestly I'm not sure if compiling is an improvement. At least when the compiler crashes, it doesn't compile code which does the wrong thing at runtime (either throw a |
Here are some relevant parts of the spec: https://www.scala-lang.org/files/archive/spec/2.11/06-expressions.html#this-and-super
This would suggest we should report an error for But, from https://www.scala-lang.org/files/archive/spec/2.11/05-classes-and-objects.html#class-members:
Which means the concrete definition |
That reminds me, we should deprecate a trait extending a class :-) |
eh? really? |
(OT here -- let's discuss at scala/scala-dev#601) |
Closes scala/bug#7216 Closes scala/bug#7288 Closes scala/bug#8693
I've updated the issue title to reflect the current status (which is: it compiles, but you can get a |
The newly linked ticket avoids the red herring method declaration.
|
The compiler ends with an java.lang.AssertionError when compiling the following file (and I have to look for another exam question....)
The error message looks as follows:
The text was updated successfully, but these errors were encountered: