Skip to content

Commit a2e2076

Browse files
committed
Clean up adaptToSubType
Add an explanatory comment and calculate GADT approx lazily.
1 parent e09e489 commit a2e2076

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
@@ -3410,13 +3410,14 @@ class Typer extends Namer
34103410
case _ =>
34113411
}
34123412

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

0 commit comments

Comments
 (0)