Skip to content

Commit 2b3c5c6

Browse files
committed
Move GADT check to typeTyped
1 parent 2414bfe commit 2b3c5c6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
448448
return typed(untpd.Apply(untpd.TypedSplice(arg), tree.expr), pt)
449449
case _ =>
450450
}
451+
case tref: TypeRef if tref.symbol.isClass && !ctx.isAfterTyper =>
452+
val setBefore = ctx.mode is Mode.GADTflexible
453+
tpt1.tpe.<:<(pt)(ctx.addMode(Mode.GADTflexible))
454+
if (!setBefore) ctx.retractMode(Mode.GADTflexible)
451455
case _ =>
452456
}
453457
ascription(tpt1, isWildcard = true)
@@ -1653,10 +1657,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
16531657
case SearchSuccess(inferred, _, _) =>
16541658
adapt(inferred, pt)
16551659
case failure: SearchFailure =>
1656-
if (
1657-
pt.isInstanceOf[ProtoType] && !failure.isInstanceOf[AmbiguousImplicits] ||
1658-
tree.tpe.<:<(pt)(ctx.addMode(Mode.GADTflexible))
1659-
) tree
1660+
if (pt.isInstanceOf[ProtoType] && !failure.isInstanceOf[AmbiguousImplicits]) tree
16601661
else err.typeMismatch(tree, pt, failure)
16611662
}
16621663
}

0 commit comments

Comments
 (0)