File tree 1 file changed +9
-2
lines changed
src/dotty/tools/dotc/typer 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
1725
1725
tree
1726
1726
}
1727
1727
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
1730
1737
else if (wtp.isInstanceOf [MethodType ]) missingArgs
1731
1738
else {
1732
1739
typr.println(i " adapt to subtype ${tree.tpe} !<:< $pt" )
You can’t perform that action at this time.
0 commit comments