The code as given does not compile anymore. We get:
bug703.scala:7 error: method f in trait B is accessed from super. It may not be abstract unless it is overridden by a member declared `abstract' and `override'
super.f;
^
bug703.scala:13 error: method f in trait C is accessed from super. It may not be abstract unless it is overridden by a member declared `abstract' and `override'
super.f;
^
The following modified example compiles and runs fine.
object Go {
trait A {
def f : Unit; // = Console.println("A");
}
trait B extends A {
abstract override def f = {
super.f;
Console.println("B");
}
}
trait C extends A {
abstract override def f = {
super.f;
Console.println("C");
}
}
trait D extends B with C {
abstract override def f = {
super.f;
}
}
class Super {
def f: Unit = Console.println("A")
}
def main(args : Array[String]) : Unit = {
object d extends Super with D
d.f;
}
}
|