Skip to content

Commit 6d4469a

Browse files
committed
Retracting special case depending on Ycheck.
I believe it's better to just bite the bullet and insert the cast. If it should become a problem, we can think of a fallback, e.g. marking the expression with a special tag, so that it does not get typechecked. But for the moment I am not sure it is an issue at all.
1 parent 05ba0ab commit 6d4469a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,12 +1725,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
17251725
tree
17261726
}
17271727
else if (tree.tpe <:< pt)
1728-
if (ctx.typeComparer.GADTused && pt.isValueType && ctx.settings.Ycheck.value.nonEmpty)
1728+
if (ctx.typeComparer.GADTused && pt.isValueType)
17291729
// Insert an explicit cast, so that -Ycheck in later phases succeeds.
17301730
// I suspect, but am not 100% sure that this might affect inferred types,
17311731
// if the expected type is a supertype of the GADT bound. It would be good to come
1732-
// up with a test case for this. For that reason, to be on the safe side
1733-
// we only insert the cast if there are Ychecks later on.
1732+
// up with a test case for this.
17341733
tree.asInstance(pt)
17351734
else
17361735
tree

0 commit comments

Comments
 (0)