Skip to content

Separate compilation fails with object extending a trait that refers to super #1144

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

Closed
smarter opened this issue Mar 4, 2016 · 0 comments
Closed

Comments

@smarter
Copy link
Member

smarter commented Mar 4, 2016

AB_1.scala:

trait A {
  def x = 3
}
trait B extends A {
  override def x = super.x * 2
}

C_2.scala:

object C extends B {
  def main(args: Array[String]) = assert(x == args(0).toInt, x)
}
% dotc AB_1.scala
% dotc C_2.scala
C_2.scala:1: error: object creation impossible, since def super$x: => Int is not defined 
object C extends B {
         ^
one error found

A.class and B.class are identical whether or not separate compilation is used:

/*
 * Decompiled with CFR 0_114.
 */
public interface A {
    default public void $init$() {
    }

    default public int x() {
        return 3;
    }
}
/*
 * Decompiled with CFR 0_114.
 */
public interface B
extends A {
    @Override
    default public void $init$() {
    }

    public /* synthetic */ int B$$super$x();

    @Override
    default public int x() {
        return this.B$$super$x() * 2;
    }
}
odersky added a commit to dotty-staging/dotty that referenced this issue Mar 10, 2016
Needed to restore the SuperAccessor flag in separate compilation.
Fixes scala#1144.
DarkDimius referenced this issue Mar 15, 2016
Pickle/unpickle SuperAccessor names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants