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
@specialize does not handle super correctly #4012
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4012?orig=1 |
@retronym said: |
@paulp said: |
@paulp said: |
@axel22 said (edited on Aug 27, 2012 5:37:05 PM UTC): |
@axel22 said: |
@axel22 said: https://github.com/axel22/scala-github/tree/issue/6265b The |
@axel22 said: private def rebindSuper(base: Symbol, member: Symbol, mixinClass: Symbol): Symbol =
exitingPickler {
var bcs = base.info.baseClasses.dropWhile(mixinClass != _).tail I don't know this phase well enough to understand why this is done this way - I'd just extract the |
@axel22 said: However, I don't think that this example is easily fixable. Let me illustrate why. From this: trait C1[A] {
def head: A = sys.error("")
}
trait C2[@specialized(Int) A] extends C1[A] {
override def head: A = super.head
}
class C3 extends C2[Int] After class C3 extends Object with C2$mcI$sp {
override <superaccessor> <specialized> <artifact> def super$head(): Int = unbox(C2$class.head(C3.this));
override <superaccessor> <specialized> <artifact> def super$head$mcI$sp(): Int = unbox(C2$class.head(C3.this));
override <specialized> def head(): Int = C2$mcI$sp$class.head(C3.this);
override <specialized> def head$mcI$sp(): Int = C2$mcI$sp$class.head$mcI$sp(C3.this);
<superaccessor> <artifact> def super$head(): Object = C1$class.head(C3.this);
<superaccessor> <specialized> <artifact> def super$head$mcI$sp(): Int = unbox(C1$class.head(C3.this));
override <bridge> <specialized> <artifact> def head(): Object = scala.Int.box(C3.this.head());
def <init>(): C3 = {
C3.super.<init>();
C1$class./*C1$class*/$init$(C3.this);
C2$class./*C2$class*/$init$(C3.this);
C2$mcI$sp$class./*C2$mcI$sp$class*/$init$(C3.this);
()
}
}; Now, the problem is (I gather) that the names of super accessors are not properly mangled (I'm not sure where exactly that happens, but I guess a `makeNotPrivate`` call is supposed to do this, and it should happen some time during specialization). Even if I fix that, there is still the fundamental problem that I cannot call abstract <specialized> trait C2$mcI$sp extends Object with C2[Int] {
...
// assuming proper name mangling for a super accessor
override <specialized> def head$mcI$sp(): Int = C2$mcI$sp.this.C2$mcI$sp$$super$head$mcI$sp();
...
} because that class C3 extends Object with C2$mcI$sp {
...
override <superaccessor> <specialized> <artifact> def C2$mcI$sp$$super$head$mcI$sp(): Int = unbox(C2$class.head(C3.this)); which in turn calls: abstract trait C2$class extends {
...
<specialized> def head$mcI$sp($this: C2): Int = scala.Int.unbox($this.head()); And then you start spinning in a cycle of recursive calls and a stack overflow happens. |
@axel22 said: |
@adriaanm said: |
@VladUreche said: |
[Edit: adding a more serious super-related crash.]
[Original report]
In the original code, I originally got a different error during mixins, using an unqualified super reference. I haven't reproduced that yet in isolation. It can be reproduced by compiling scalala with SBT from: https://github.com/retronym/Scalala/tree/ab592a34bc1b5492ab2df65d4ba96d6c585ff724
This results in:
I'll try and get a smaller test case for this one, and update this ticket.
See also #3651
What versions of the following are you using?
Scala: 2.8.0 / 2.8.1
Java: 1.6
The text was updated successfully, but these errors were encountered: