Skip to content

Commit 64a71f6

Browse files
committed
Fix issue with GADT not typechecking without bind in match
1 parent 04b0e85 commit 64a71f6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
16051605
}
16061606
tree
16071607
}
1608-
else if (tree.tpe <:< pt) tree
1608+
else if (tree.tpe.<:<(pt)(ctx.addMode(Mode.GADTflexible))) tree
16091609
else if (wtp.isInstanceOf[MethodType]) missingArgs
16101610
else {
16111611
typr.println(i"adapt to subtype ${tree.tpe} !<:< $pt")

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)