Aladdin - Scala Bugtracking
[#576] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-04-25 18:44:35.0
subject type inference ordering bug
code
package lampion.collections;

abstract class BaseListXXX {
  type Node <: BaseNode;
  abstract class BaseNode {
  }
}  
trait PriorityTreeXXX extends BaseListXXX {
	type Node <: BasicTreeNode;
  
  trait BasicTreeNode extends BaseNode {
    def sibling: Node = null; 
    def insert(dir : Int, node : Node) /* : Unit */ = {
      if (true) sibling.insert(node);
      //else insert(node);
      
    }
    def insert(node : Node) : Unit  = {}
  }
}
what happened
Note: can reproduce from command line.

Important: you don't get the crash (or even a type error) if the two insert methods are defined in the opposite \
order (define insert/1 before insert/2). 

Exception:

bash-3.00$ ~/runtime-workspace/scala/dists/latest/bin/scalac -sourcepath /home/mcdirmid/runtime-workspace/s\
cala/src/library/ -d ../bin/ lampion
/collections/PriorityTreeXXX.scala 
exception when traversing {
  ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1)).apply(Bas\
icTreeNode.this.sibling)
}.insert(node)
exception when traversing if (true)
  {
    ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1)).apply(B\
asicTreeNode.this.sibling)
  }.insert(node)
exception when traversing def insert(dir: scala.Int, node: PriorityTreeXXX.this.Node): scala.Unit = if (true)
  {
    ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1)).apply(B\
asicTreeNode.this.sibling)
  }.insert(node)
exception when traversing PriorityTreeXXX.this.BaseNode with scala.ScalaObject {
  def sibling: PriorityTreeXXX.this.Node = null;
  def insert(dir: scala.Int, node: PriorityTreeXXX.this.Node): scala.Unit = if (true)
    {
      ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1)).apply\
(BasicTreeNode.this.sibling)
    }.insert(node);
  def insert(node: PriorityTreeXXX.this.Node): scala.Unit = ()
}
exception when traversing abstract trait BasicTreeNode extends PriorityTreeXXX.this.BaseNode with scala.ScalaObj\
ect {
  def sibling: PriorityTreeXXX.this.Node = null;
  def insert(dir: scala.Int, node: PriorityTreeXXX.this.Node): scala.Unit = if (true)
    {
      ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1)).apply\
(BasicTreeNode.this.sibling)
    }.insert(node);
  def insert(node: PriorityTreeXXX.this.Node): scala.Unit = ()
}
exception when traversing BaseListXXX with scala.ScalaObject {
  type Node >: scala.All <: PriorityTreeXXX.this.BasicTreeNode;
  abstract trait BasicTreeNode extends PriorityTreeXXX.this.BaseNode with scala.ScalaObject {
    def sibling: PriorityTreeXXX.this.Node = null;
    def insert(dir: scala.Int, node: PriorityTreeXXX.this.Node): scala.Unit = if (true)
      {
        ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1)).app\
ly(BasicTreeNode.this.sibling)
      }.insert(node);
    def insert(node: PriorityTreeXXX.this.Node): scala.Unit = ()
  }
}
exception when traversing abstract trait PriorityTreeXXX extends BaseListXXX with scala.ScalaObject {
  type Node >: scala.All <: PriorityTreeXXX.this.BasicTreeNode;
  abstract trait BasicTreeNode extends PriorityTreeXXX.this.BaseNode with scala.ScalaObject {
    def sibling: PriorityTreeXXX.this.Node = null;
    def insert(dir: scala.Int, node: PriorityTreeXXX.this.Node): scala.Unit = if (true)
      {
        ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1)).app\
ly(BasicTreeNode.this.sibling)
      }.insert(node);
    def insert(node: PriorityTreeXXX.this.Node): scala.Unit = ()
  }
}
exception when traversing package collections {
  abstract class BaseListXXX extends java.lang.Object with scala.ScalaObject {
    def this(): lampion.collections.BaseListXXX = {
      BaseListXXX.super.this();
      ()
    };
    type Node >: scala.All <: BaseListXXX.this.BaseNode;
    abstract class BaseNode extends java.lang.Object with scala.ScalaObject {
      def this(): BaseListXXX.this.BaseNode = {
        BaseNode.super.this();
        ()
      }
    }
  };
  abstract trait PriorityTreeXXX extends BaseListXXX with scala.ScalaObject {
    type Node >: scala.All <: PriorityTreeXXX.this.BasicTreeNode;
    abstract trait BasicTreeNode extends PriorityTreeXXX.this.BaseNode with scala.ScalaObject {
      def sibling: PriorityTreeXXX.this.Node = null;
      def insert(dir: scala.Int, node: PriorityTreeXXX.this.Node): scala.Unit = if (true)
        {
          ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1)).a\
pply(BasicTreeNode.this.sibling
)
        }.insert(node);
      def insert(node: PriorityTreeXXX.this.Node): scala.Unit = ()
    }
  }
}
exception when traversing package lampion {
  package collections {
    abstract class BaseListXXX extends java.lang.Object with scala.ScalaObject {
      def this(): lampion.collections.BaseListXXX = {
        BaseListXXX.super.this();
        ()
      };
      type Node >: scala.All <: BaseListXXX.this.BaseNode;
      abstract class BaseNode extends java.lang.Object with scala.ScalaObject {
        def this(): BaseListXXX.this.BaseNode = {
          BaseNode.super.this();
          ()
        }
      }
    };
    abstract trait PriorityTreeXXX extends BaseListXXX with scala.ScalaObject {
      type Node >: scala.All <: PriorityTreeXXX.this.BasicTreeNode;
      abstract trait BasicTreeNode extends PriorityTreeXXX.this.BaseNode with scala.ScalaObject {
        def sibling: PriorityTreeXXX.this.Node = null;
        def insert(dir: scala.Int, node: PriorityTreeXXX.this.Node): scala.Unit = if (true)
          {
            ((eta$1: PriorityTreeXXX.this.Node) => scala.this.Predef.identity[PriorityTreeXXX.this.Node](eta$1))\
.apply(BasicTreeNode.this.sibli
ng)
          }.insert(node);
        def insert(node: PriorityTreeXXX.this.Node): scala.Unit = ()
      }
    }
  }
}

Exception in thread "main" java.lang.Error: assertion failed
        at scala.Predef$.assert(Predef.scala:166)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transformArgs(UnCurry.scala:248)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$15.apply(UnCurry.scala:352)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$15.apply(UnCurry.scala:350)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withNeedLift$0(UnCurry.scala:288)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:350)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:984)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:390)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$16.apply(Trees.scala:945)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$16.apply(Trees.scala:944)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1046)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:943)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.scala$tools$nsc$transform$UnCurry$UnCurryTransfo\
rmer$$super$transform(UnCurry.s
cala:328)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$8.apply(UnCurry.scala:328)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$8.apply(UnCurry.scala:312)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withNeedLift$0(UnCurry.scala:288)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:311)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1040)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1038)
        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:1038)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:964)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.scala$tools$nsc$transform$UnCurry$UnCurryTransfo\
rmer$$super$transform(UnCurry.s
cala:328)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$19$$anonfun$20.apply(UnCurry.scala:387)\

        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$19$$anonfun$20.apply(UnCurry.scala:387)\

        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withInConstructorFlag$0(UnCurry.scala:296)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$19.apply(UnCurry.scala:387)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$19.apply(UnCurry.scala:387)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withNewTyper$0(UnCurry.scala:304)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:387)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer.transformTemplate(Trees.scala:1026)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$13.apply(Trees.scala:932)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$13.apply(Trees.scala:932)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1046)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:931)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:390)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1040)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1038)
        at scala.List$.loop$0(List.scala:232)
        at scala.List$.mapConserve(List.scala:249)
        at scala.tools.nsc.ast.Trees$Transformer.transformStats(Trees.scala:1038)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:964)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.scala$tools$nsc$transform$UnCurry$UnCurryTransfo\
rmer$$super$transform(UnCurry.s
cala:328)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$19$$anonfun$20.apply(UnCurry.scala:387)\

        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$19$$anonfun$20.apply(UnCurry.scala:387)\

        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withInConstructorFlag$0(UnCurry.scala:296)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$19.apply(UnCurry.scala:387)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$19.apply(UnCurry.scala:387)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withNewTyper$0(UnCurry.scala:304)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:387)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer.transformTemplate(Trees.scala:1026)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$13.apply(Trees.scala:932)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$13.apply(Trees.scala:932)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1046)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:931)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:390)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1040)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1038)
        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:1038)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$12.apply(Trees.scala:928)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$12.apply(Trees.scala:928)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1046)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:927)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.scala$tools$nsc$transform$UnCurry$UnCurryTransfo\
rmer$$super$transform(UnCurry.s
cala:328)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$18.apply(UnCurry.scala:384)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$18.apply(UnCurry.scala:384)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withNewTyper$0(UnCurry.scala:304)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:384)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1040)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$25.apply(Trees.scala:1038)
        at scala.List$.loop$0(List.scala:232)
        at scala.List$.mapConserve(List.scala:249)
        at scala.tools.nsc.ast.Trees$Transformer.transformStats(Trees.scala:1038)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$12.apply(Trees.scala:928)
        at scala.tools.nsc.ast.Trees$Transformer$$anonfun$12.apply(Trees.scala:928)
        at scala.tools.nsc.ast.Trees$Transformer.atOwner(Trees.scala:1046)
        at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:927)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.scala$tools$nsc$transform$UnCurry$UnCurryTransfo\
rmer$$super$transform(UnCurry.s
cala:328)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$18.apply(UnCurry.scala:384)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer$$anonfun$18.apply(UnCurry.scala:384)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.withNewTyper$0(UnCurry.scala:304)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.mainTransform(UnCurry.scala:384)
        at scala.tools.nsc.transform.UnCurry$UnCurryTransformer.transform(UnCurry.scala:78)
        at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:1041)
        at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:22)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:213)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:202)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:202)
        at scala.Iterator$class.foreach(Iterator.scala:285)
        at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:216)
        at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:202)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:432)
        at scala.tools.nsc.Global$Run.compile(Global.scala:490)
        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)

what expected
[back to overview]
Changes of this bug report
Martin  edited on  2006-04-25 20:26:47.0
You now get: bug576.scala:14 error: overloaded method insert needs result type if (true) sibling.insert(node); ^ one error found