-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Default methods, mixin and invokeSpecial on JVM #1392
Comments
could you quickly summarize your idea here..? :) |
Two options:
|
btw: the |
I also think we should try (2). My logic is that we are working around a VM restriction, namely that one cannot call specific methods in superclasses. Scala.JS and Scala.native do not have the problem; for them it is trivial. So rather than generate avalanches of additional bytecode I would prefer if we could fix the problem by giving the target VM more capabilities through reflection-base libraries. The big unknown is how well this would optimize. To find out we have to get an implementation first. |
I retract my remark. @DarkDimius and I just had session where we played with it. Here's the code:
@DarkDimius will summarize our conclusions. |
I take it by "that points to method that was found using reflection" you mean to use Sounds like a good plan. I'd considered something similar once to implement access to private members without publicing them in bytecode. |
@retronym Good find! If it is easy to do then let's do it. But the problem is less pervasive than I thought initially. Essentially it only applies when an explicit super call targets a class method, not a trait method. Mixin forwarders should not be affected. |
ping @lrytz @adriaanm. We've decided, that at least for dotty we would prefer to warn for cases that may misbehave. We have played with HotSpot and reread the spec several times, and decided to:
Depending on frequency of those warning we may decide not to implement the scheme |
Handled in scalac by scala/scala@a980fde which got refined by scala/scala#5377 |
…ctly A call `super[T].m` that resolves to `A.m` cannot be translated to correct bytecode if `A` is a class (not a trait / interface), but not the direct superclass. Invokespecial would select an overriding method in the direct superclass, rather than `A.m`. We allow this if there are statically no intervening overrides. Based on scala/scala@a980fde and scala/scala@0a84038 Note that unlike Scala 2 we do not need to check if the mixin part of a Super is to a direct parent here because this is already done in TypeAssigner. Co-Authored-By: Jason Zaugg <jzaugg@gmail.com> Co-Authored-By: Lukas Rytz <lukas.rytz@gmail.com>
…ctly A call `super[T].m` that resolves to `A.m` cannot be translated to correct bytecode if `A` is a class (not a trait / interface), but not the direct superclass. Invokespecial would select an overriding method in the direct superclass, rather than `A.m`. We allow this if there are statically no intervening overrides. Based on scala/scala@a980fde and scala/scala@0a84038 Note that unlike Scala 2 we do not need to check if the mixin part of a Super is to a direct parent here because this is already done in TypeAssigner. Co-Authored-By: Jason Zaugg <jzaugg@gmail.com> Co-Authored-By: Lukas Rytz <lukas.rytz@gmail.com>
Fix #1392: Disallow super-calls that cannot be implemented correctly
…ctly A call `super[T].m` that resolves to `A.m` cannot be translated to correct bytecode if `A` is a class (not a trait / interface), but not the direct superclass. Invokespecial would select an overriding method in the direct superclass, rather than `A.m`. We allow this if there are statically no intervening overrides. Based on scala/scala@a980fde and scala/scala@0a84038 Note that unlike Scala 2 we do not need to check if the mixin part of a Super is to a direct parent here because this is already done in TypeAssigner. Co-Authored-By: Jason Zaugg <jzaugg@gmail.com> Co-Authored-By: Lukas Rytz <lukas.rytz@gmail.com>
scala/scala-dev#143 (comment)
I have a fix in mind, but I will not have time to try it out before going for vacation.
Making a note for myself to come back to it in September.
The text was updated successfully, but these errors were encountered: