Aladdin - Scala Bugtracking
[#719] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-08-31 12:55:04.0
subject mixins + private objects + separate compilation = very very bad
code
// A.scala
package test;
trait A {
  trait Node {
    def foo : Unit = {}
  }
}

// B.scala
package test; 
import scala.collection.mutable._;
trait B extends A {
  private object xxx extends HashMap[String,String];
  trait Node extends super.Node {
    override def foo = {
      super.foo;
      xxx("Hello") = "World";
      Console.println("from B");
    }
  }
}
// E.scala
package test;
class E extends B {
  class Node extends super.Node;
  (new Node).foo;
}
what happened
sean-mcdirmids-computer:~/workspace/test10/src mcdirmid$ ../../scala/build/quick/bin/scalac -d . -sourcepath . t\
est/*.scala
sean-mcdirmids-computer:~/workspace/test10/src mcdirmid$ javap -private test.E
Compiled from "E.scala"
public class test.E extends java.lang.Object implements test.B,scala.ScalaObject{
    private test.B$xxx$ test$B$$xxx$module;
    public test.E();
    public int $tag();
    public final test.B$xxx$ test$B$$xxx();
}

sean-mcdirmids-computer:~/workspace/test10/src mcdirmid$ ../../scala/build/quick/bin/scalac -d . -sourcepath . t\
est/E.scala
sean-mcdirmids-computer:~/workspace/test10/src mcdirmid$ javap -private test.E
Compiled from "E.scala"
public class test.E extends java.lang.Object implements test.B,scala.ScalaObject{
    public test.E();
    public int $tag();
}

sean-mcdirmids-computer:~/workspace/test10/src mcdirmid$ 
Running it is even more fun:
Exception in thread "main" java.lang.AbstractMethodError: test.E.test$B$$xxx()Ltest/B$xxx$;
	at test.B$Node$class.foo(B.scala:8)
	at test.E$Node.foo(E.scala:4)
	at test.E.(E.scala:5)
	at test.Test$.main(Test.scala:5)
	at test.Test.main(Test.scala)
what expected Compiling E.scala separately from B.scala should also generate the xxx module and its accessor. Right now things will just crash at run-time.
[back to overview]
Changes of this bug report
Martin  edited on  2006-09-04 19:30:38.0
Martin  edited on  2006-09-12 00:53:11.0
Martin  edited on  2006-09-19 23:04:40.0