-
Notifications
You must be signed in to change notification settings - Fork 21
correct superaccessor from abstract override lazy val #3167
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
Imported From: https://issues.scala-lang.org/browse/SI-3167?orig=1 |
@paulp said: |
@adriaanm said: |
@adriaanm said: |
@gkossakowski said: |
@retronym said: |
@adriaanm said: trait Base { def name: String }
trait OverrideLazy extends Base { override def name = "One" }
trait AbstractOverrideLazy extends Base { abstract override def name = super.name }
class ShouldNotLoop extends Base with OverrideLazy with AbstractOverrideLazy // super.name refers to OverrideLazy's name
/* Decompiled to Java
public interface Base {
public abstract String name();
}
public interface OverrideLazy extends Base {
public abstract String name();
}
public interface AbstractOverrideLazy extends Base {
public abstract String AbstractOverrideLazy$$super$name();
public abstract String name();
}
public abstract class OverrideLazy$class {
public static String name(OverrideLazy $this) { return "One"; }
public static void $init$(OverrideLazy overridelazy) {}
}
public abstract class AbstractOverrideLazy$class {
public static String name(AbstractOverrideLazy $this) { return $this.AbstractOverrideLazy$$super$name(); }
public static void $init$(AbstractOverrideLazy abstractoverridelazy){}
}
import scala.runtime.BoxedUnit;
public class ShouldNotLoop implements OverrideLazy, AbstractOverrideLazy {
private String name$lzycompute() {
synchronized(this) {
if(!bitmap$0) {
name = AbstractOverrideLazy.class.name(this);
bitmap$0 = true;
}
BoxedUnit _tmp = BoxedUnit.UNIT;
}
return name;
}
public String name() { return bitmap$0 ? name : name$lzycompute(); }
public String AbstractOverrideLazy$$super$name() { return name(); }
// when replacing the `lazy val`s by `def`s, we get the correct superaccessor
// public String AbstractOverrideLazy$$super$name() { return OverrideLazy.class.name(this); }
public ShouldNotLoop()
{
OverrideLazy.class.$init$(this);
AbstractOverrideLazy.class.$init$(this);
}
private final String name;
private volatile boolean bitmap$0;
}
*/ |
Christian Schlichtherle (christian_schlichtherle) said: |
@som-snytt said: Welcome to Scala 2.12.0-M5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_92).
Type in expressions for evaluation. Or try :help.
scala> :pa
// Entering paste mode (ctrl-D to finish)
trait Thing { def name: String }
trait Thing1 extends Thing { override lazy val name = "One" }
trait Thing2 extends Thing { abstract override lazy val name = super.name }
// Exiting paste mode, now interpreting.
defined trait Thing
defined trait Thing1
defined trait Thing2
scala> val t = new Thing with Thing1 with Thing2
t: Thing with Thing1 with Thing2 = $anon$1@18eec010
scala> t.name
res0: String = One
|
Christian Schlichtherle (christian_schlichtherle) said: |
@adriaanm said: |
I have a trait defined as
I'm trying to stack it using
where Thing1 and Thing2 are defined as
I'm getting a StackOverflowError when trying to access t.name. This happens with both Scala 2.9.0.Beta1 and the March 9th nightly build.
The text was updated successfully, but these errors were encountered: