Skip to content

Fix #3004 and simplify exhaustivity check #3011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 25, 2017
198 changes: 92 additions & 106 deletions compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/patmat/exhausting.check
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
21: Pattern Match Exhaustivity: List(_), List(_, _, _, _*)
21: Pattern Match Exhaustivity: List(_), List(_, _, _, _: _*)
27: Pattern Match Exhaustivity: Nil
32: Pattern Match Exhaustivity: List(_, _*)
32: Pattern Match Exhaustivity: List(_, _: _*)
39: Pattern Match Exhaustivity: Bar3
44: Pattern Match Exhaustivity: (Bar2, Bar2)
53: Pattern Match Exhaustivity: (Bar2, Bar2), (Bar2, Bar1), (Bar1, Bar3), (Bar1, Bar2)
2 changes: 1 addition & 1 deletion tests/patmat/i2363.check
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
15: Pattern Match Exhaustivity: List(_, _*)
15: Pattern Match Exhaustivity: List(_, _: _*)
21: Pattern Match Exhaustivity: _: Expr
12 changes: 12 additions & 0 deletions tests/patmat/i3004.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object O {
sealed trait Fruit
object Apple extends Fruit
object Banana extends Fruit
sealed class C(f1: Fruit, f2: Fruit)

object C {
def unapply(c: C): Some[Banana.type] = Some(Banana)
}

def m(c: C) = c match { case C(b) => b }
}
2 changes: 1 addition & 1 deletion tests/patmat/t4408.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2: Pattern Match Exhaustivity: List(_, _, _, _*)
2: Pattern Match Exhaustivity: List(_, _, _, _: _*)
2 changes: 1 addition & 1 deletion tests/patmat/t5440.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2: Pattern Match Exhaustivity: (Nil, List(_, _*)), (List(_, _*), Nil)
2: Pattern Match Exhaustivity: (Nil, List(_, _: _*)), (List(_, _: _*), Nil)
2 changes: 1 addition & 1 deletion tests/patmat/t6420.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5: Pattern Match Exhaustivity: (_: List, Nil), (_: List, List(true, _*)), (_: List, List(false, _*))
5: Pattern Match Exhaustivity: (_: List, Nil), (_: List, List(true, _: _*)), (_: List, List(false, _: _*))
8 changes: 4 additions & 4 deletions tests/patmat/t7020.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
3: Pattern Match Exhaustivity: List(_, _*)
10: Pattern Match Exhaustivity: List(_, _*)
17: Pattern Match Exhaustivity: List(_, _*)
24: Pattern Match Exhaustivity: List(_, _*)
3: Pattern Match Exhaustivity: List(_, _: _*)
10: Pattern Match Exhaustivity: List(_, _: _*)
17: Pattern Match Exhaustivity: List(_, _: _*)
24: Pattern Match Exhaustivity: List(_, _: _*)
4 changes: 3 additions & 1 deletion tests/patmat/t9232.check
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
13: Pattern Match Exhaustivity: Node2(), Node1(Foo(_))
13: Pattern Match Exhaustivity: Node2()
17: Pattern Match Exhaustivity: Node2(), Node1(Foo(Nil)), Node1(Foo(List(_, _: _*)))
21: Pattern Match Exhaustivity: Node2(), Node1(Foo(Nil))
10 changes: 9 additions & 1 deletion tests/patmat/t9232.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ case class Node2() extends Tree

object Test {
def transformTree(tree: Tree): Any = tree match {
case Node1(Foo(1)) => ???
case Node1(Foo(_: _*)) => ???
}

def transformTree2(tree: Tree): Any = tree match {
case Node1(Foo(1, _: _*)) => ???
}

def transformTree3(tree: Tree): Any = tree match {
case Node1(Foo(x, _: _*)) => ???
}
}