Aladdin - Scala Bugtracking
[#692] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-08-06 16:35:07.0
subject overflow crash with implicit parameters and type parameters
code
abstract class test3 {
  trait Type0[+T];
  trait Type[T] extends Type0[T];
  trait ClassType0[+C <: Object] extends Type0[C];
  abstract class RefType[C <: Object] extends Type[C];
  case class ObjectType extends RefType[Object];
  abstract class ClassType[C <: Z, Z <: Object](zuper : RefType[Z]) extends RefType[C];
  

  case class FooType extends ClassType[Foo,Object](ObjectType);
  implicit def typeOfFoo = FooType();

  case class BarType[T <: Foo](tpeT : RefType[T]) extends ClassType[Bar[T],Foo](FooType);
  implicit def typeOfBar[T <: Foo](implicit elem : RefType[T]) : RefType[Bar[T]] = 
    BarType(elem);
  

  class Foo[A <: Object];
  class Bar[A <: Foo](implicit tpeA : Type[A]) extends Foo;
}
what happened
test/test3.scala:13 error: class Foo takes type parameters
  case class FooType extends ClassType[Foo,Object](ObjectType);
                                       ^
test/test3.scala:16 error: class Foo takes type parameters
  case class BarType[T <: Foo](tpeT : RefType[T]) extends ClassType[Bar[T],Foo](FooType);
                                                                           ^
test/test3.scala:16 error: class Foo takes type parameters
  case class BarType[T <: Foo](tpeT : RefType[T]) extends ClassType[Bar[T],Foo](FooType);
                          ^
test/test3.scala:17 error: class Foo takes type parameters
  implicit def typeOfBar[T <: Foo](implicit elem : RefType[T]) : RefType[Bar[T]] =
                              ^
Exception in thread "main" java.lang.StackOverflowError
	at scala.tools.nsc.Global$analyzer$.instantiate(Global.scala:232)
	at scala.tools.nsc.typechecker.Infer$class.instantiate(Infer.scala:62)
	at scala.tools.nsc.Global$analyzer$.instantiate(Global.scala:232)
	at scala.tools.nsc.typechecker.Infer$class.instantiate(Infer.scala:62)
	at scala.tools.nsc.Global$analyzer$.instantiate(Global.scala:232)
	at scala.tools.nsc.typechecker.Infer$class.instantiate(Infer.scala:62)
	at scala.tools.nsc.Global$analyzer$.instantiate(Global.scala:232)
	at scala.tools.nsc.typechecker.Infer$class.instantiate(Infer.scala:62)
	at scala.tools.nsc.Global$analyzer$.instantiate(Global.scala:232)
	at scala.tools.nsc.typechecker.Infer$class.instantiate(Infer.scala:62)
	at scala.tools.nsc.Global$analyzer$.instantiate(Global.scala:232)
	at scala.tools.nsc.typechecker.Infer$class.instantiate(Infer.scala:62)
	at scala.tools.nsc.Global$analyzer$.instantiate(Global.scala:232)
	at scala.tools.nsc.typechecker.Infer$class.instantiate(Infer.scala:62)
...
...
what expected no crashing
[back to overview]
Changes of this bug report
Martin  edited on  2006-08-20 16:39:08.0