Aladdin - Scala Bugtracking
[#247] project: compiler priority: low category: missing feature
submitter assigned to status date submitted
Erik Martin fixed 2003-12-03 16:41:20.0
subject Secondary constructors
code
class Order[t](less:(t,t) => Boolean,equal:(t,t) => Boolean) {}

trait Map[A, B](factory:MapFactory[A]) with scala.collection.Map[A, B] {}
abstract class MapFactory[A] {
  def Empty[B]:Map[A,B];
}

class TreeMapFactory[KEY](newOrder:Order[KEY]) with MapFactory[KEY] {
  val order = newOrder;
  def Empty[V] = new TreeMap[KEY,V](new TreeMapFactory[KEY](order));
}

class Tree[KEY,Entry](order:Order[KEY]) { 
  def size =0;
}

class TreeMap[KEY,VALUE](factory:TreeMapFactory[KEY]) extends Tree[KEY,Pair[KEY,VALUE]](factory.order) with Map[KEY, VALUE](factory) {
  val order = factory.order;
  def this(newOrder:Order[KEY]) = this(new TreeMapFactory[KEY](newOrder));
  def get(key:KEY) = null;
  def elements:Iterator[Pair[KEY,VALUE]] = null;
}



what happened
scalac -d ~/tmp/classes ~/tmp/Test.scala 
Exception in thread "main" java.lang.AssertionError: type KEY in constructor TreeMap
        at scalac.transformer.LambdaLift$FreeVars.markFree(LambdaLift.java:178)
        at scalac.transformer.LambdaLift$FreeVars.markFree(LambdaLift.java:182)
        at scalac.transformer.LambdaLift$FreeVars.markFree(LambdaLift.java:182)
        at scalac.transformer.LambdaLift$FreeVars.access$116(LambdaLift.java:109)
        at scalac.transformer.LambdaLift$FreeVars$16.apply(LambdaLift.java:210)
        at scalac.symtab.Type$Map.map(Type.java:1078)
        at scalac.symtab.Type$Map.map(Type.java:989)
        at scalac.transformer.LambdaLift$FreeVars$16.apply(LambdaLift.java:220)
        at scalac.transformer.LambdaLift$FreeVars.transform(LambdaLift.java:227)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:125)
        at scalac.transformer.LambdaLift$FreeVars.transform(LambdaLift.java:268)
        at scalac.ast.Transformer.transform(Transformer.java:291)
        at scalac.ast.Transformer.transform(Transformer.java:305)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:57)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:116)
        at scalac.transformer.LambdaLift$FreeVars.transform(LambdaLift.java:235)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:41)
        at scalac.transformer.OwnerTransformer.transformTemplateStat(OwnerTransformer.java:87)
        at scalac.transformer.OwnerTransformer.transformTemplateStats(OwnerTransformer.java:76)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:68)
        at scalac.transformer.OwnerTransformer.transform(OwnerTransformer.java:100)
        at scalac.transformer.LambdaLift$FreeVars.transform(LambdaLift.java:235)
        at scalac.ast.Transformer.transform(Transformer.java:282)
        at scalac.transformer.OwnerTransformer.apply(OwnerTransformer.java:35)
        at scalac.transformer.LambdaLift$FreeVars.initialize(LambdaLift.java:315)
        at scalac.transformer.LambdaLift.apply(LambdaLift.java:54)
        at scalac.transformer.LambdaLiftPhase.apply(LambdaLiftPhase.java:28)
        at scalac.Global.compile(Global.java:300)
        at scalac.Global.compile(Global.java:272)
        at scala.tools.scalac.Main$.main(sources/scala/tools/scalac/Main.scala:33)
        at scala.tools.scalac.Main.main(sources/scala/tools/scalac/Main.scala)
what expected Not a compiler crash.
[back to overview]
Changes of this bug report
Erik  edited on  2003-12-03 16:41:52.0
Michel  edited on  2003-12-03 16:56:09.0
The problem is due to the secondary constructor of class TreeMap, and is the general problem discussed once during some meeting related to secondary constructors and type arguments.
Martin  edited on  2004-01-08 15:40:29.0
I cathc this case now with a message `secondary constructors for parameterized classes not yet implemented'. We need to come back to this later.
Martin  edited on  2006-03-30 19:00:00.0
Fixed in version 2