Aladdin - Scala Bugtracking
[#696] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-08-10 12:47:19.0
subject implicit parameter crash
code
object TypeUtil0 {
  trait Type[+T];
  implicit def WithType[S,T](implicit tpeS : Type[S], tpeT : Type[T]) : Type[S with T] = null
  as[Any](null);
  def as[T](x : Any)(implicit tpe : Type[T]) = null;
}
what happened
Exception in thread "main" java.lang.StackOverflowError
	at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:1303)
	at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:1227)
	at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:1343)
	at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:1303)
	at scala.List$.loop$0(List.scala:232)
	at scala.List$.mapConserve(List.scala:249)
	at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:1287)
	at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:1255)
	at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:1343)
	at scala.tools.nsc.symtab.Types$Type.asSeenFrom(Types.scala:194)
	at scala.tools.nsc.symtab.Types$Type.memberType(Types.scala:221)
	at scala.tools.nsc.typechecker.Infer$Inferencer.checkAccessible(Infer.scala:253)
	at scala.tools.nsc.typechecker.Typers$Typer.typedIdent$0(Typers.scala:1424)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1704)
	at scala.tools.nsc.typechecker.Typers$Typer.typedImplicit(Typers.scala:1874)
        // begin infinite recursion here
	at scala.tools.nsc.typechecker.Typers$Typer.isApplicable$0(Typers.scala:1934)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$87.apply(Typers.scala:1936)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$87.apply(Typers.scala:1936)
	at scala.List.filter(List.scala:694)
	at scala.tools.nsc.typechecker.Typers$Typer.applicableInfos$0(Typers.scala:1936)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$89.apply(Typers.scala:1941)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$89.apply(Typers.scala:1941)
	at scala.List.map(List.scala:651)
	at scala.tools.nsc.typechecker.Typers$Typer.searchImplicit$0(Typers.scala:1941)
	at scala.tools.nsc.typechecker.Typers$Typer.inferImplicit(Typers.scala:1961)
	at scala.tools.nsc.typechecker.Typers$Typer.implicitArg$0(Typers.scala:1970)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$95.apply(Typers.scala:1974)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$95.apply(Typers.scala:1974)
	at scala.List.map(List.scala:651)
	at scala.tools.nsc.typechecker.Typers$Typer.applyImplicitArgs(Typers.scala:1974)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:384)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:383)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:377)
	at scala.tools.nsc.typechecker.Typers$Typer.typedImplicit(Typers.scala:1876)
        // repeat forever
	at scala.tools.nsc.typechecker.Typers$Typer.isApplicable$0(Typers.scala:1934)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$87.apply(Typers.scala:1936)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$87.apply(Typers.scala:1936)
	at scala.List.filter(List.scala:694)
        ....
what expected
[back to overview]
Changes of this bug report
Martin  edited on  2006-08-20 13:12:45.0
We now get:
bug696.scala:3 error: implicit method WithType is not contractive,
 because the implicit parameter type TypeUtil0.this.Type[S]
 is not strictly contained in the signature TypeUtil0.this.Type[S with T]
  implicit def WithType[S,T](implicit tpeS : Type[S], tpeT : Type[T]) : Type[S with T] = null
           ^
bug696.scala:4 error: no implicit argument matching parameter type TypeUtil0.this.Type[scala.Any] was found.
  as[Any](null);
         ^
two errors found