-
Notifications
You must be signed in to change notification settings - Fork 14
Bridge or omit troublesome additional abstract methods in specialized traits #36
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
@retronym: The additional method can most likely be eliminated, but you'll need additional logic in specialOverrides. |
Thanks, @VladUreche. I'm prototypying a change here; scala/scala@scala:2.12.x...retronym:topic/trait-default-specialization During my digging, this old commit seemed relevant; aeda72b |
The problem is I can't grasp all the implications of this change -- the model where the generic class/trait is extended by the specializations is very difficult to reason about, esp. when it interacts with mixin 👎 Lacking a nice mental model of this, have you tried the community build with the change? 😆 |
Here's the diff of the terminal phase trees for the the test case I was working with: https://gist.github.com/25a12fb3e6258ff0d5ee Notice that the class def t(a: Int): Unit = Test$TInt$1.this.t$mcI$sp(a); I'll also tossed this to the community build: https://scala-ci.typesafe.com/view/scala-2.12.x/job/scala-2.12.x-integrate-community-build/109/console |
LGTM, the bodies you eliminate have to exist at least in the class/trait that offers an implementation for the method (and possibly in overriders). Or, at least, I can't come up with a counterexample... |
Introduced in 2bde392 The previous commit defends the intended part of the change, which was discussed in scala/scala-dev#36
Closing because it doesn't seem to have become an issue. But (@retronym) we can reopen and move it to scala/bug if need be. |
Interaction with specialization
Specialization adds another small challenge. In the example below, notice how
apply : (Int)V
has been added to the specialized sub interface. A Java subclass ofT$mcI$sp
would need to implement bothapply
-s.T$mcI$sp
is not a functional interface, so can't be used inLambdaMetafactory
/ (e.g. as the target type of a Java lambda expressions).We run straight into this problem with the specialized Scala function traits.
Contrast with a regular trait that inherits another trait:
We should investigate whether addition of this method by specialization is necessary / intentional. If we cannot omit it, we do have the possibility to bridge it.
Scala callers never route into this method:
The text was updated successfully, but these errors were encountered: