From 2b3c5c60cea83b3add2774bbfa840aa91312cb01 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 7 Jun 2016 16:05:50 +0200 Subject: Move GADT check to `typeTyped` --- src/dotty/tools/dotc/typer/Typer.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 734f1c660..07710d3b1 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -448,6 +448,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit return typed(untpd.Apply(untpd.TypedSplice(arg), tree.expr), pt) case _ => } + case tref: TypeRef if tref.symbol.isClass && !ctx.isAfterTyper => + val setBefore = ctx.mode is Mode.GADTflexible + tpt1.tpe.<:<(pt)(ctx.addMode(Mode.GADTflexible)) + if (!setBefore) ctx.retractMode(Mode.GADTflexible) case _ => } ascription(tpt1, isWildcard = true) @@ -1653,10 +1657,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case SearchSuccess(inferred, _, _) => adapt(inferred, pt) case failure: SearchFailure => - if ( - pt.isInstanceOf[ProtoType] && !failure.isInstanceOf[AmbiguousImplicits] || - tree.tpe.<:<(pt)(ctx.addMode(Mode.GADTflexible)) - ) tree + if (pt.isInstanceOf[ProtoType] && !failure.isInstanceOf[AmbiguousImplicits]) tree else err.typeMismatch(tree, pt, failure) } } -- cgit v1.2.3