Browse files

SI-8060 Avoid infinite loop with higher kinded type alias

The `dealiasLocals` map was assuming that:

    tp.isAliasType implies (tp.dealias ne tp)

This isn't true if `!typeParamsMatchArgs`.

This commit avoids the infinite loop by checking whether or not
dealiasing progresses.
  • Loading branch information...
1 parent 0c92704 commit bb427a34165b0338be8b23baeb61ac0591b3c0a1 @retronym retronym committed Dec 10, 2013
Showing with 12 additions and 1 deletion.
  1. +1 −1 src/compiler/scala/tools/nsc/typechecker/Typers.scala
  2. +11 −0 test/files/pos/t8060.scala
View
2 src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3826,7 +3826,7 @@ trait Typers extends Modes with Adaptations with Tags {
val normalizeLocals = new TypeMap {
def apply(tp: Type): Type = tp match {
case TypeRef(pre, sym, args) =>
- if (sym.isAliasType && containsLocal(tp)) apply(tp.dealias)
+ if (sym.isAliasType && containsLocal(tp) && (tp.dealias ne tp)) apply(tp.dealias)
else {
if (pre.isVolatile)
InferTypeWithVolatileTypeSelectionError(tree, pre)
View
11 test/files/pos/t8060.scala
@@ -0,0 +1,11 @@
+trait M[F[_]]
+
+trait P[A] {
+ type CC[X] = P[X]
+ def f(p: A => Boolean): M[CC]
+}
+
+trait Other {
+ // was infinite loop trying to dealias `x$1.CC`
+ def g[A](p: A => Boolean): P[A] => M[P] = _ f p
+}

0 comments on commit bb427a3

Please sign in to comment.