File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/dotty/tools/dotc/typer Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1725,8 +1725,15 @@ 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 ) tree.asInstance(pt)
1729- else tree
1728+ if (ctx.typeComparer.GADTused && pt.isValueType && ctx.settings.Ycheck .value.nonEmpty)
1729+ // Insert an explicit cast, so that -Ycheck in later phases succeeds.
1730+ // I suspect, but am not 100% sure that this might affect inferred types,
1731+ // 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.
1734+ tree.asInstance(pt)
1735+ else
1736+ tree
17301737 else if (wtp.isInstanceOf [MethodType ]) missingArgs
17311738 else {
17321739 typr.println(i " adapt to subtype ${tree.tpe} !<:< $pt" )
You can’t perform that action at this time.
0 commit comments