Skip to content

Commit dcdcd86

Browse files
committed
Harden tryReduce
When compiling kind-incorrect code in neg/anykind3.scala, substParams fails with an index-out-bounds exception. It is called from tryReduce via instantiate. We know there are several scenarios where this can happen - Sandro has detected a couple of others. This commit avoids the problem by aborting the reduce if there is an index out of bounds.
1 parent 9c9b0ae commit dcdcd86

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ class TypeApplications(val self: Type) extends AnyVal {
367367
case _ => false
368368
}
369369
}
370-
if ((dealiased eq stripped) || followAlias) dealiased.instantiate(args)
370+
if ((dealiased eq stripped) || followAlias)
371+
try dealiased.instantiate(args)
372+
catch { case ex: IndexOutOfBoundsException => AppliedType(self, args) }
371373
else AppliedType(self, args)
372374
}
373375
else dealiased.resType match {

0 commit comments

Comments
 (0)