Skip to content

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

Closed
@smarter

Description

@smarter

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;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions