Skip to content

Commit 30d0a8e

Browse files
committed
Fix infinite loop in normalization
Unconditionally normalizing type applications results can result in an infinite loop (e.g. in tests/neg-custom-args/matchtype-loop.scala), so this normalization should happen more conservatively.
1 parent eabd95a commit 30d0a8e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,16 @@ class TypeApplications(val self: Type) extends AnyVal {
371371
// just eta-reduction (ignoring variance annotations).
372372
// See i2201*.scala for examples where more aggressive
373373
// reduction would break type inference.
374-
dealiased.paramRefs == dealiasedArgs
374+
dealiased.paramRefs == dealiasedArgs ||
375+
defn.isCompiletimeAppliedType(tyconBody.typeSymbol)
375376
case _ => false
376377
}
377378
}
378379
if ((dealiased eq stripped) || followAlias)
379-
try dealiased.instantiate(args).normalized
380+
try {
381+
val instantiated = dealiased.instantiate(args)
382+
if (followAlias) instantiated.normalized else instantiated
383+
}
380384
catch { case ex: IndexOutOfBoundsException => AppliedType(self, args) }
381385
else AppliedType(self, args)
382386
}

0 commit comments

Comments
 (0)