Skip to content

Commit 914d465

Browse files
authored
Merge pull request #1309 from felixmulder/topic/fix#1307
Fix issue with GADT not typechecking without bind in match
2 parents af93e88 + 2b3c5c6 commit 914d465

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

Lines changed: 4 additions & 0 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)

tests/pos/i1307.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Term[A]
2+
class Number(val n: Int) extends Term[Int]
3+
object Test {
4+
def f[B](t: Term[B]): B = t match {
5+
case y: Number => y.n
6+
}
7+
}

0 commit comments

Comments
 (0)