Skip to content

Supertraits need to be filled in #1423

Closed
@odersky

Description

@odersky

Consider the following test:

    class B { def m: Int = 0 }
    class C extends B { override def m = 4 }
    trait T1 extends B { override def m = 1 }
    trait T2 extends T1 { override def m = 2 }
    trait T3 extends T1 { override def m = 3 }

    trait T4 extends T1
    class D extends B {
      def f() = println(super[B].m)
    }

    object Test extends C with T2 with T3 with T4 {
      def main(args: Array[String]): Unit = {
        println(m)
        println(super[T2].m)
        println(super[T3].m)
        println(super[T4].m)
        new D().f()
      }
    }

Running this gives:

3
2
3
Exception in thread "main" java.lang.IncompatibleClassChangeError: Interface method reference: T1.m()I, is in an indirect superinterface of Test$
    at Test$.main(test.scala:17)
    at Test.main(test.scala)

If I revert 468ff9c the example runs fine. The problem seems to be that the supertrait T1 got dropped even though there is a super reference (via super[T4].m) to it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions