Skip to content
This repository
Browse code

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...
commit bb427a34165b0338be8b23baeb61ac0591b3c0a1 1 parent 0c92704
Jason Zaugg authored December 10, 2013
2  src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3826,7 +3826,7 @@ trait Typers extends Modes with Adaptations with Tags {
3826 3826
       val normalizeLocals = new TypeMap {
3827 3827
         def apply(tp: Type): Type = tp match {
3828 3828
           case TypeRef(pre, sym, args) =>
3829  
-            if (sym.isAliasType && containsLocal(tp)) apply(tp.dealias)
  3829
+            if (sym.isAliasType && containsLocal(tp) && (tp.dealias ne tp)) apply(tp.dealias)
3830 3830
             else {
3831 3831
               if (pre.isVolatile)
3832 3832
                 InferTypeWithVolatileTypeSelectionError(tree, pre)
11  test/files/pos/t8060.scala
... ...
@@ -0,0 +1,11 @@
  1
+trait M[F[_]]
  2
+ 
  3
+trait P[A] {
  4
+  type CC[X] = P[X]
  5
+  def f(p: A => Boolean): M[CC]
  6
+}
  7
+ 
  8
+trait Other {
  9
+  // was infinite loop trying to dealias `x$1.CC`
  10
+  def g[A](p: A => Boolean): P[A] => M[P] = _ f p
  11
+}

0 notes on commit bb427a3

Please sign in to comment.
Something went wrong with that request. Please try again.