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 @@ -1689,8 +1689,15 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1689
1689
tree
1690
1690
}
1691
1691
else if (tree.tpe <:< pt)
1692
- if (ctx.typeComparer.GADTused ) tree.asInstance(pt)
1693
- else tree
1692
+ if (ctx.typeComparer.GADTused && pt.isValueType && ctx.settings.Ycheck .value.nonEmpty)
1693
+ // Insert an explicit cast, so that -Ycheck in later phases succeeds.
1694
+ // I suspect, but am not 100% sure that this might affect inferred types,
1695
+ // 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.
1698
+ tree.asInstance(pt)
1699
+ else
1700
+ tree
1694
1701
else if (wtp.isInstanceOf [MethodType ]) missingArgs
1695
1702
else {
1696
1703
typr.println(i " adapt to subtype ${tree.tpe} !<:< $pt" )
You can’t perform that action at this time.
0 commit comments