Skip to content

Commit bb427a3

Browse files
committed
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.
1 parent 0c92704 commit bb427a3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3826,7 +3826,7 @@ trait Typers extends Modes with Adaptations with Tags {
38263826
val normalizeLocals = new TypeMap {
38273827
def apply(tp: Type): Type = tp match {
38283828
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)
38303830
else {
38313831
if (pre.isVolatile)
38323832
InferTypeWithVolatileTypeSelectionError(tree, pre)

test/files/pos/t8060.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 commit comments

Comments
 (0)