Aladdin - Scala Bugtracking
[#609] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-05-18 20:11:48.0
subject separate compilation crash
code
test/MyOffsetList.scala

package test;
abstract class MyLinkedList  {
  type Node <: NodeImpl;
  def init : Node;
  final class Segment(node : Node);
  trait NodeImpl {
    def insertAfter(node : Node) : Unit = insertAfter(new Segment(node));
    def insertAfter(segment : Segment) = {}
  }
}
trait MyOffsetList extends MyLinkedList {
  type Node <: NodeImpl;
  trait NodeImpl  extends super.NodeImpl {
    override def insertAfter(segment : Segment) = super.insertAfter(segment);
  }
}

test/MyScanner.scala

package test;

class MyScannerTest extends MyOffsetList {
  type Node = NodeImpl;
  def init = new NodeImpl {}
}
what happened
Compile both files together first, then compiler just MyScanner.scala (don't need to be in resident mode), trans\
cript as follows:

bash-3.00$ scalac -d ../bin -sourcepath . test/*.scala
bash-3.00$ scalac -d ../bin -sourcepath . test/MyScanner.scala 
exception when traversing java.lang.Object with test.NodeImpl$class {
  private   val $outer : test.MyScannerTest = _;
     def $outer(): MyScannerTest.this.type = $anon$0.this.$outer ;
  def this($outer: test.MyScannerTest): $anon$0 = {
    if ($outer.eq(null))
      throw new java.lang.NullPointerException.this()
    else
      $anon$0.this.$outer  = $outer;
    {
      $anon$0.super.this();
      ()
    };
    $anon$0.this./*NodeImpl$class*/$init$($outer);
    $anon$0.this./*NodeImpl$class*/$init$($outer);
    ()
  }
}
exception when traversing final  class $anon$0 extends java.lang.Object with test.NodeImpl$class {
  private   val $outer : test.MyScannerTest = _;
     def $outer(): MyScannerTest.this.type = $anon$0.this.$outer ;
  def this($outer: test.MyScannerTest): $anon$0 = {
    if ($outer.eq(null))
      throw new java.lang.NullPointerException.this()
    else
      $anon$0.this.$outer  = $outer;
    {
      $anon$0.super.this();
      ()
    };
    $anon$0.this./*NodeImpl$class*/$init$($outer);
    $anon$0.this./*NodeImpl$class*/$init$($outer);
    ()
  }
}
exception when traversing package test {
  class MyScannerTest extends test.MyLinkedList with test.MyOffsetList with scala.ScalaObject {
    def init(): java.lang.Object with MyScannerTest.this.NodeImpl = {
      new test.$anon$0.this(MyScannerTest.this)
    };
     def init(): test.MyLinkedList#NodeImpl = MyScannerTest.this.init().$asInstanceOf[test.NodeImpl]();
\

    def this(): test.MyScannerTest = {
      {
        MyScannerTest.super.this();
        ()
      };
      MyScannerTest.this./*MyOffsetList$class*/$init$();
      ()
    }
  };
  final  class $anon$0 extends java.lang.Object with test.NodeImpl$class {
    private   val $outer : test.MyScannerTest = _;
       def $outer(): MyScannerTest.this.type = $anon$0.this.$outer ;
    def this($outer: test.MyScannerTest): $anon$0 = {
      if ($outer.eq(null))
        throw new java.lang.NullPointerException.this()
      else
        $anon$0.this.$outer  = $outer;
      {
        $anon$0.super.this();
        ()
      };
      $anon$0.this./*NodeImpl$class*/$init$($outer);
      $anon$0.this./*NodeImpl$class*/$init$($outer);
      ()
    }
  }
}
Exception in thread "main" java.lang.Error: assertion failed
	at scala.Predef$.assert(Predef.scala:170)
	at scala.tools.nsc.symtab.Types$Type.memberType(Types.scala:209)
	at scala.tools.nsc.symtab.Symbols$Symbol$$anonfun$6.apply(Symbols.scala:628)
	at scala.tools.nsc.symtab.Symbols$Symbol$$anonfun$6.apply(Symbols.scala:627)
	at scala.List.filter(List.scala:695)
	at scala.tools.nsc.symtab.Symbols$Symbol.filter(Symbols.scala:501)
	at scala.tools.nsc.symtab.Symbols$Symbol.matchingSymbol(Symbols.scala:627)
	at scala.tools.nsc.symtab.Symbols$Symbol.overridingSymbol(Symbols.scala:636)
	at scala.tools.nsc.transform.Mixin$$anonfun$2.apply(Mixin.scala:52)
	at scala.tools.nsc.transform.Mixin$$anonfun$2.apply(Mixin.scala:42)
	at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:41)
	at scala.tools.nsc.transform.Mixin.scala$tools$nsc$transform$Mixin$$rebindSuper(Mixin.scala:42)
	at scala.tools.nsc.transform.Mixin$$anonfun$9.apply(Mixin.scala:149)
	at scala.tools.nsc.transform.Mixin$$anonfun$9.apply(Mixin.scala:129)
	at scala.List.foreach(List.scala:681)
	at scala.tools.nsc.transform.Mixin.mixinMembers$0(Mixin.scala:129)
	at scala.tools.nsc.transform.Mixin$$anonfun$10.apply(Mixin.scala:160)
	at scala.tools.nsc.transform.Mixin$$anonfun$10.apply(Mixin.scala:160)
	at scala.List.foreach(List.scala:681)
	at scala.tools.nsc.transform.Mixin.addMixedinMembers(Mixin.scala:160)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.preTransform(Mixin.scala:219)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer.transformTemplate(Trees.scala:1024)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$13.apply(Trees.scala:930)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$13.apply(Trees.scala:930)
	at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1044)
	at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:929)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1038)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1036)
	at scala.List$.loop$0(List.scala:232)
	at scala.List$.mapConserve(List.scala:249)
	at scala.List$.loop$0(List.scala:236)
	at scala.List$.mapConserve(List.scala:249)
	at scala.tools.nsc.ast.Trees$Transformer.transformStats(Trees.scala:1036)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$12.apply(Trees.scala:926)
	at scala.tools.nsc.ast.Trees$Transformer$$anonfun$12.apply(Trees.scala:926)
	at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1044)
	at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:925)
	at scala.tools.nsc.transform.Mixin$MixinTransformer.transform(Mixin.scala:406)
	at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:1039)
	at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:22)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:214)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:203)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:203)
	at scala.Iterator$class.foreach(Iterator.scala:304)
	at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:216)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:203)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:450)
	at scala.tools.nsc.Global$Run.compile(Global.scala:508)
	at scala.tools.nsc.Main$.process(Main.scala:60)
	at scala.tools.nsc.Main$.main(Main.scala:82)
	at scala.tools.nsc.Main.main(Main.scala)

Problem seems to be in the two methods both having the same name insertAfter, if we rename one method, the bug g\ oes away. Actually, its even stranger, if we don't instantiate Node, the bug also goes away. And if we don't ove\ rride insertAfter, the bug also goes away.
what expected
[back to overview]
Changes of this bug report
Sean  edited on  2006-05-18 20:16:20.0
Sean  edited on  2006-05-19 14:59:47.0
Updating bug report with new experience.
Martin  edited on  2006-05-26 15:41:23.0