Skip to content

Commit

Permalink
Fix typo leading to incorrect unreachable case warning (#16528)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarter authored Dec 15, 2022
2 parents ca5a264 + 49af9cf commit ef653b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ trait SpaceLogic {
case (Typ(tp1, _), Prod(tp2, fun, ss)) =>
isSubType(tp1, tp2)
&& covers(fun, tp1, ss.length)
&& isSubspace(Prod(tp2, fun, signature(fun, tp2, ss.length).map(Typ(_, false))), b)
&& isSubspace(Prod(tp2, fun, signature(fun, tp1, ss.length).map(Typ(_, false))), b)
case (Prod(_, fun1, ss1), Prod(_, fun2, ss2)) =>
isSameUnapply(fun1, fun2) && ss1.zip(ss2).forall((isSubspace _).tupled)
}
Expand Down
7 changes: 7 additions & 0 deletions tests/patmat/isSubspace-Typ-Prod.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
case class Foo[T](x: T)
class Bar extends Foo[String]("")

def test(x: Any) = x match
case Foo(1) =>
case _: Bar => // used to warn about unreachable case
// case _: Foo[_] => // still warns, something else is wrong

0 comments on commit ef653b6

Please sign in to comment.