Skip to content

Commit 72916ea

Browse files
committed
Clean up adaptToSubType
Add an explanatory comment and calculate GADT approx lazily.
1 parent baaaa6c commit 72916ea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,13 +3407,14 @@ class Typer extends Namer
34073407
case _ =>
34083408
}
34093409

3410-
val gadtApprox = Inferencing.approximateGADT(wtp)
3410+
// try GADT approximation, but only if we're trying to select a member
3411+
// Member lookup cannot take GADTs into account b/c of cache, so we
3412+
// approximate types based on GADT constraints instead. For an example,
3413+
// see MemberHealing in gadt-approximation-interaction.scala.
3414+
lazy val gadtApprox = Inferencing.approximateGADT(wtp)
34113415
gadts.println(
34123416
i"""GADT approximation {
34133417
approximation = $gadtApprox
3414-
pt.isInstanceOf[SelectionProto] = ${pt.isInstanceOf[SelectionProto]}
3415-
ctx.gadt.nonEmpty = ${ctx.gadt.nonEmpty}
3416-
ctx.gadt = ${ctx.gadt.debugBoundsDescription}
34173418
pt.isMatchedBy = ${
34183419
if (pt.isInstanceOf[SelectionProto])
34193420
pt.asInstanceOf[SelectionProto].isMatchedBy(gadtApprox).toString

0 commit comments

Comments
 (0)