-
Notifications
You must be signed in to change notification settings - Fork 21
Extending specific kind of trait compiled by scala 3 leads to NoSuchMethodError #12184
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
@bishabosha this isn't a blocker for 2.13.4, is it? (🤞) |
I'm not sure what the policy should be in this case. On the other hand, Dotty has its own issue where it does not generate the essentially, this is showing that for the trait definition: trait IOApp {
protected val foo = 23
def run(args: List[String]): Int
final def main(args: Array[String]): Unit = {
sys.exit(run(args.toList))
}
}
object IOApp {
trait Simple extends IOApp {
def run: Unit
final def run(args: List[String]): Int = {
run
0
}
}
} on scala 2 both |
If I remember correctly this is expected, with the goal to have more binary stability. But adding a field to a trait is not binary compatible anyway, so I'm not sure. Maybe @retronym remembers. |
I see, thanks for the explanation, Jamie. Whether it's a bug or not in Scala 2, we couldn't make scalac 2.13.4 suddenly stop emitting the trait initialiser method in IOApp.Simple as that would break that trait's downstream users. So in order for Scala 3 jars to be consumable Dotty needs to mirror Scala 2.13's choices. (edit: unless, of course, you can shim something at tasty reading time... but that would add complexity IMO) So it's "notabug" IMO, but a Dotty issue. |
Yes I see now, this issue is nothing due to tasty reader, but dotty not matching the flags for Scala 2, - the IOApp.Simple should be a pure constructor in this case in tasty, but is not |
In addition (from @sjrd) Dotty needs to align for shared trait usage. |
reproduction steps
using Dotty
0.27-0-RC1
, compileusing Scala
2.13.4-bin-8891679
, withIOApp
on the class path, compileproblem
when you run
Main.main
you get the runtime error:this only happens if
IOApp
does something in its constructor.When
IOApp
is instead compiled by Scala2.13.3
there is noIOApp.Simple.$init$
method generated or called.The text was updated successfully, but these errors were encountered: