Skip to content

Commit 96fecb0

Browse files
committed
Add an explanatory comment
1 parent b9239a2 commit 96fecb0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,11 @@ class Typer extends Namer
16021602
val guard1 = typedExpr(tree.guard, defn.BooleanType)
16031603
var body1 = ensureNoLocalRefs(typedExpr(tree.body, pt1), pt1, ctx.scope.toList)
16041604
if ctx.gadt.nonEmpty then
1605+
// Store GADT constraint to later retrieve it (in PostTyper, for now).
1606+
// GADT constraints are necessary to correctly check bounds of type app,
1607+
// see tests/pos/i12226 and issue #12226. It might be possible that this
1608+
// will end up taking too much memory. If it does, we should just limit
1609+
// how much GADT constraints we infer - it's always sound to infer less.
16051610
pat1.putAttachment(InferredGadtConstraints, ctx.gadt)
16061611
if (pt1.isValueType) // insert a cast if body does not conform to expected type if we disregard gadt bounds
16071612
body1 = body1.ensureConforms(pt1)(using originalCtx)

0 commit comments

Comments
 (0)