Skip to content

Commit 5c987c2

Browse files
committed
Better documentation for GADT casts
1 parent 27f6370 commit 5c987c2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3532,7 +3532,12 @@ class Typer extends Namer
35323532
adaptToSubType(wtp)
35333533
case CompareResult.OKwithGADTUsed
35343534
if pt.isValueType
3535-
&& !inContext(ctx.fresh.setGadt(EmptyGadtConstraint)) { tree.tpe.widenExpr frozen_<:< pt } =>
3535+
&& !inContext(ctx.fresh.setGadt(EmptyGadtConstraint)) {
3536+
(tree.tpe.widenExpr frozen_<:< pt)
3537+
// we overshot; a cast is not needed, after all. (this happens a lot. We should
3538+
// find out whether we can make GADTused more precise)
3539+
.showing(i"false alarm for $tree: ${tree.tpe.widenExpr} vs $pt in ${ctx.source}", gadts)
3540+
} =>
35363541
// Insert an explicit cast, so that -Ycheck in later phases succeeds.
35373542
// I suspect, but am not 100% sure that this might affect inferred types,
35383543
// if the expected type is a supertype of the GADT bound. It would be good to come

0 commit comments

Comments
 (0)