File tree 2 files changed +14
-1
lines changed
compiler/src/dotty/tools/dotc/typer 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1830,7 +1830,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1830
1830
ctx.typeComparer.GADTused = false
1831
1831
if (ctx.mode is Mode .Pattern ) {
1832
1832
tree match {
1833
- case _ : RefTree | _ : Literal if ! isVarPattern(tree) =>
1833
+ case _ : RefTree | _ : Literal
1834
+ if ! isVarPattern(tree) &&
1835
+ ! (tree.tpe <:< pt)(ctx.addMode(Mode .GADTflexible )) =>
1834
1836
checkCanEqual(pt, wtp, tree.pos)(ctx.retractMode(Mode .Pattern ))
1835
1837
case _ =>
1836
1838
}
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ sealed trait Foo [A ]
3
+ case object FooI extends Foo [Int ]
4
+ case class FooS (b : Boolean ) extends Foo [String ]
5
+
6
+ def algFoo [A ](foo : Foo [A ]): A =
7
+ foo match {
8
+ case FooI => 42
9
+ case FooS (b) => " foo"
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments