Skip to content

Commit f89e618

Browse files
authored
Merge pull request #3011 from dotty-staging/fix-3004
Fix #3004 and simplify exhaustivity check
2 parents db9fcbc + f1d45a7 commit f89e618

File tree

10 files changed

+126
-118
lines changed

10 files changed

+126
-118
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 92 additions & 106 deletions
Large diffs are not rendered by default.

tests/patmat/exhausting.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
21: Pattern Match Exhaustivity: List(_), List(_, _, _, _*)
1+
21: Pattern Match Exhaustivity: List(_), List(_, _, _, _: _*)
22
27: Pattern Match Exhaustivity: Nil
3-
32: Pattern Match Exhaustivity: List(_, _*)
3+
32: Pattern Match Exhaustivity: List(_, _: _*)
44
39: Pattern Match Exhaustivity: Bar3
55
44: Pattern Match Exhaustivity: (Bar2, Bar2)
66
53: Pattern Match Exhaustivity: (Bar2, Bar2), (Bar2, Bar1), (Bar1, Bar3), (Bar1, Bar2)

tests/patmat/i2363.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
15: Pattern Match Exhaustivity: List(_, _*)
1+
15: Pattern Match Exhaustivity: List(_, _: _*)
22
21: Pattern Match Exhaustivity: _: Expr

tests/patmat/i3004.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
object O {
2+
sealed trait Fruit
3+
object Apple extends Fruit
4+
object Banana extends Fruit
5+
sealed class C(f1: Fruit, f2: Fruit)
6+
7+
object C {
8+
def unapply(c: C): Some[Banana.type] = Some(Banana)
9+
}
10+
11+
def m(c: C) = c match { case C(b) => b }
12+
}

tests/patmat/t4408.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2: Pattern Match Exhaustivity: List(_, _, _, _*)
1+
2: Pattern Match Exhaustivity: List(_, _, _, _: _*)

tests/patmat/t5440.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2: Pattern Match Exhaustivity: (Nil, List(_, _*)), (List(_, _*), Nil)
1+
2: Pattern Match Exhaustivity: (Nil, List(_, _: _*)), (List(_, _: _*), Nil)

tests/patmat/t6420.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5: Pattern Match Exhaustivity: (_: List, Nil), (_: List, List(true, _*)), (_: List, List(false, _*))
1+
5: Pattern Match Exhaustivity: (_: List, Nil), (_: List, List(true, _: _*)), (_: List, List(false, _: _*))

tests/patmat/t7020.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
3: Pattern Match Exhaustivity: List(_, _*)
2-
10: Pattern Match Exhaustivity: List(_, _*)
3-
17: Pattern Match Exhaustivity: List(_, _*)
4-
24: Pattern Match Exhaustivity: List(_, _*)
1+
3: Pattern Match Exhaustivity: List(_, _: _*)
2+
10: Pattern Match Exhaustivity: List(_, _: _*)
3+
17: Pattern Match Exhaustivity: List(_, _: _*)
4+
24: Pattern Match Exhaustivity: List(_, _: _*)

tests/patmat/t9232.check

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
13: Pattern Match Exhaustivity: Node2(), Node1(Foo(_))
1+
13: Pattern Match Exhaustivity: Node2()
2+
17: Pattern Match Exhaustivity: Node2(), Node1(Foo(Nil)), Node1(Foo(List(_, _: _*)))
3+
21: Pattern Match Exhaustivity: Node2(), Node1(Foo(Nil))

tests/patmat/t9232.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ case class Node2() extends Tree
1111

1212
object Test {
1313
def transformTree(tree: Tree): Any = tree match {
14-
case Node1(Foo(1)) => ???
14+
case Node1(Foo(_: _*)) => ???
15+
}
16+
17+
def transformTree2(tree: Tree): Any = tree match {
18+
case Node1(Foo(1, _: _*)) => ???
19+
}
20+
21+
def transformTree3(tree: Tree): Any = tree match {
22+
case Node1(Foo(x, _: _*)) => ???
1523
}
1624
}

0 commit comments

Comments
 (0)