[#703] | project: compiler | priority: low | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Sean | Martin | fixed | 2006-08-16 07:56:44.0 | |
subject | super accessor crash | |||
code |
object Go { trait A { def f : Unit; // = Console.println("A"); } trait B extends A { override def f = { super.f; Console.println("B"); } } trait C extends A { override def f = { super.f; Console.println("C"); } } trait D extends B with C { override def f = { super.f; } } def main(args : Array[String]) : Unit = { object d extends D; d.f; } } |
|||
what happened | exception when traversing java.lang.Object with test.D$class with scala.ScalaObject$class { def this(): object d$1 = { { d$1.super.this(); () }; d$1.this./*B$class*/$init$(); d$1.this./*C$class*/$init$(); d$1.this./*D$class*/$init$(); () } } exception when traversing final class d$1 extends java.lang.Object with test.D$class with scala.ScalaObject$clas\ s { def this(): object d$1 = { { d$1.super.this(); () }; d$1.this./*B$class*/$init$(); d$1.this./*C$class*/$init$(); d$1.this./*D$class*/$init$(); () } } exception when traversing package test { final class Go extends java.lang.Object with scala.ScalaObject { def main(args: scala.Array[java.lang.String]): scala.Unit = { var d$module$0: scala.runtime.ObjectRef = new scala.runtime.ObjectRef.this(null); Go.this.d$0(d$module$0).f() }; final private |
|||
what expected | ||||
[back to overview] |
Martin edited on 2006-08-20 12:52:06.0 |
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; } } |