-
Notifications
You must be signed in to change notification settings - Fork 21
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
Wrong method signatures generated for class inheriting from trait specialized on AnyRef #6101
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6101?orig=1 |
@gkossakowski said: |
@axel22 said (edited on Jul 18, 2012 3:33:47 PM UTC): The trees after specialize for the Scala file example from the bug report body: package <empty> {
abstract trait CustomFunction1[@specialized(scala.Int) T1 >: Nothing <: Any, @specialized(scala.`package`.AnyRef) R >: Nothing <: Any] extends Object {
def apply(v1: T1): R;
<specialized> def apply$mcLI$sp(v1: Int): R = CustomFunction1.this.apply(v1.asInstanceOf[T1]())
};
class UnitFunctionBridge[T >: Nothing <: Any] extends Object with CustomFunction1[T,scala.runtime.BoxedUnit] {
def <init>(): UnitFunctionBridge[T] = {
UnitFunctionBridge.super.<init>();
()
};
final override def apply(t: T): scala.runtime.BoxedUnit = scala.runtime.BoxedUnit.UNIT
};
abstract <specialized> trait CustomFunction1$mcLI$sp[R$sp >: Nothing <: AnyRef] extends Object with CustomFunction1[Int,R$sp] {
<specialized> def apply(v1: Int): R$sp
}
} Observe We think that The other bug describes how generating this bridge is not done even when there is no specialization. |
@VladUreche said: |
@VladUreche said: |
We generate wrong method signarues for AnyRef specialization. Let me give you the following example:
Let's see what -Xprint:cleanup gives us:
The relevant part is (from UnitFunctionBridge:
<specialized> def apply$mcLI$sp(v1: Int): Object = foo.CustomFunction1$class.apply$mcLI$sp(UnitFunctionBridge.this, v1);
The return type here is wrong. It should be BoxedUnit because we implement generic, specialized interface of CustomFuction1[T1, R] and we substitute R with BoxedUnit.
This matters because the class shown above cannot be instantiated from Java:
if you try to compile you'll get:
The text was updated successfully, but these errors were encountered: