diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/exhausting.check | 2 | ||||
-rw-r--r-- | test/files/neg/exhausting.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t7669.check | 7 | ||||
-rw-r--r-- | test/files/neg/t7669.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t7669.scala | 13 | ||||
-rw-r--r-- | test/files/run/virtpatmat_casting.scala | 1 |
6 files changed, 24 insertions, 2 deletions
diff --git a/test/files/neg/exhausting.check b/test/files/neg/exhausting.check index c573eb3e15..619849693c 100644 --- a/test/files/neg/exhausting.check +++ b/test/files/neg/exhausting.check @@ -1,5 +1,5 @@ exhausting.scala:21: warning: match may not be exhaustive. -It would fail on the following input: List(_, _, _) +It would fail on the following inputs: List(_), List(_, _, _) def fail1[T](xs: List[T]) = xs match { ^ exhausting.scala:27: warning: match may not be exhaustive. diff --git a/test/files/neg/exhausting.scala b/test/files/neg/exhausting.scala index 5554ee2671..01c34f7039 100644 --- a/test/files/neg/exhausting.scala +++ b/test/files/neg/exhausting.scala @@ -17,7 +17,7 @@ object Test { case (_: Foo[_], _: Foo[_]) => () } - // fails for: ::(_, ::(_, ::(_, _))) + // fails for: ::(_, Nil), ::(_, ::(_, ::(_, _))), ... def fail1[T](xs: List[T]) = xs match { case Nil => "ok" case x :: y :: Nil => "ok" diff --git a/test/files/neg/t7669.check b/test/files/neg/t7669.check new file mode 100644 index 0000000000..c090ed18ce --- /dev/null +++ b/test/files/neg/t7669.check @@ -0,0 +1,7 @@ +t7669.scala:9: warning: match may not be exhaustive. +It would fail on the following input: NotHandled(_) + def exhausto(expr: Expr): Unit = expr match { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7669.flags b/test/files/neg/t7669.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t7669.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t7669.scala b/test/files/neg/t7669.scala new file mode 100644 index 0000000000..12441ec056 --- /dev/null +++ b/test/files/neg/t7669.scala @@ -0,0 +1,13 @@ +object Test { + + sealed abstract class Expr + // Change type of `arg` to `Any` and the exhaustiveness warning + // is issued below + case class Op(arg: Expr) extends Expr + case class NotHandled(num: Double) extends Expr + + def exhausto(expr: Expr): Unit = expr match { + case Op(Op(_)) => + case Op(_) => + } +} diff --git a/test/files/run/virtpatmat_casting.scala b/test/files/run/virtpatmat_casting.scala index d970abae90..22ac29bc3b 100644 --- a/test/files/run/virtpatmat_casting.scala +++ b/test/files/run/virtpatmat_casting.scala @@ -4,5 +4,6 @@ object Test extends App { // since the :: extractor's argument must be a ::, there has to be a cast before its unapply is invoked case x :: y :: z :: a :: xs => xs ++ List(x) case x :: y :: z :: xs => xs ++ List(x) + case _ => List(0) }) } |