diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 4 | ||||
-rw-r--r-- | tests/pos/i1307.scala | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 4f27912f1..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) diff --git a/tests/pos/i1307.scala b/tests/pos/i1307.scala new file mode 100644 index 000000000..1dd922321 --- /dev/null +++ b/tests/pos/i1307.scala @@ -0,0 +1,7 @@ +class Term[A] +class Number(val n: Int) extends Term[Int] +object Test { + def f[B](t: Term[B]): B = t match { + case y: Number => y.n + } +} |