aboutsummaryrefslogtreecommitdiff
path: root/tests/patmat/gadt.scala
diff options
context:
space:
mode:
authorliu fengyun <liufengyunchina@gmail.com>2016-07-21 10:45:14 +0200
committerliu fengyun <liufengyunchina@gmail.com>2016-08-24 10:26:59 +0200
commitcc02243fbe8b7290265e1bdf540e4c2f256df199 (patch)
treebd83dcabb8de09fa48b9373b9431ef8c481da5ed /tests/patmat/gadt.scala
parent1a7618f32c6d8060c3a87ce633645440d500aa7a (diff)
downloaddotty-cc02243fbe8b7290265e1bdf540e4c2f256df199.tar.gz
dotty-cc02243fbe8b7290265e1bdf540e4c2f256df199.tar.bz2
dotty-cc02243fbe8b7290265e1bdf540e4c2f256df199.zip
add test set for exhaustivity and redundancy check
Diffstat (limited to 'tests/patmat/gadt.scala')
-rw-r--r--tests/patmat/gadt.scala58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/patmat/gadt.scala b/tests/patmat/gadt.scala
new file mode 100644
index 000000000..0541ed61f
--- /dev/null
+++ b/tests/patmat/gadt.scala
@@ -0,0 +1,58 @@
+object Test {
+ sealed trait Expr[T]
+ case class IntLit(i: Int) extends Expr[Int]
+ case class BooleanLit(b: Boolean) extends Expr[Boolean]
+ case class Sum(l: Expr[Int], r: Expr[Int]) extends Expr[Int]
+ case class Or(l: Expr[Boolean], r: Expr[Boolean]) extends Expr[Boolean]
+
+ def foo1a(x: Expr[Int]) = x match {
+ case _: IntLit => true
+ case _: Sum => true
+ }
+
+ def foo1b(x: Expr[Int]) = x match {
+ case _: Sum => true
+ }
+
+ def foo2a(x: Expr[Boolean]) = x match {
+ case _: BooleanLit => true
+ case _: Or => true
+ }
+
+ def foo2b(x: Expr[Boolean]) = x match {
+ case _: BooleanLit => true
+ }
+
+ def foo3a(x: Expr[Boolean]) = x match {
+ case _: BooleanLit => true
+ case _: Or => true
+ // case _: Sum => true
+ }
+
+ def foo3b(x: Expr[Int]) = x match {
+ case _: IntLit => true
+ case _: Sum => true
+ // case _: Or => true
+ }
+
+ def foo4a(x: Expr[_]) = x match {
+ case _: IntLit => true
+ case _: Sum => true
+ case _: BooleanLit => true
+ case _: Or => true
+ }
+
+ def foo4b(x: Expr[_]) = x match {
+ case _: Sum => true
+ case _: Or => true
+ }
+
+ def foo5a[T <: Int](x: Expr[T]) = x match {
+ case _: IntLit => true
+ case _: Sum => true
+ }
+
+ def foo5b[T <: Int](x: Expr[T]) = x match {
+ case _: IntLit => true
+ }
+}