Skip to content

Commit 79b83bd

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 624d6ad commit 79b83bd

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
@@ -1689,12 +1689,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
16891689
tree
16901690
}
16911691
else if (tree.tpe <:< pt)
1692-
if (ctx.typeComparer.GADTused && pt.isValueType && ctx.settings.Ycheck.value.nonEmpty)
1692+
if (ctx.typeComparer.GADTused && pt.isValueType)
16931693
// Insert an explicit cast, so that -Ycheck in later phases succeeds.
16941694
// I suspect, but am not 100% sure that this might affect inferred types,
16951695
// if the expected type is a supertype of the GADT bound. It would be good to come
1696-
// up with a test case for this. For that reason, to be on the safe side
1697-
// we only insert the cast if there are Ychecks later on.
1696+
// up with a test case for this.
16981697
tree.asInstance(pt)
16991698
else
17001699
tree

0 commit comments

Comments
 (0)