diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-26 08:07:34 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-26 08:08:43 -0700 |
commit | 43bf1ea07ccf4ccf5a63743e322d4b64320fc1c1 (patch) | |
tree | a16411c3d7839a7fa4a3ffd5d5520f43129a5b5a /test | |
parent | 25d03629d87861640fc9d56d4378b985dfb7efd3 (diff) | |
download | scala-43bf1ea07ccf4ccf5a63743e322d4b64320fc1c1.tar.gz scala-43bf1ea07ccf4ccf5a63743e322d4b64320fc1c1.tar.bz2 scala-43bf1ea07ccf4ccf5a63743e322d4b64320fc1c1.zip |
Yet more tests for unchecked warnings.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/unchecked3.check | 26 | ||||
-rw-r--r-- | test/files/neg/unchecked3.scala | 50 |
2 files changed, 75 insertions, 1 deletions
diff --git a/test/files/neg/unchecked3.check b/test/files/neg/unchecked3.check index f2905124f2..f4f0c74257 100644 --- a/test/files/neg/unchecked3.check +++ b/test/files/neg/unchecked3.check @@ -10,4 +10,28 @@ unchecked3.scala:28: error: non-variable type argument Int in type pattern A2[In unchecked3.scala:32: error: non-variable type argument Int in type pattern B2[_,Int] is unchecked since it is eliminated by erasure /* warn */ def twotypes5[T](x: A2[T]) = x match { case _: B2[_, Int] => true } ^ -four errors found +unchecked3.scala:40: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure + /* warn */ case _: Array[List[String]] => () + ^ +unchecked3.scala:43: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure + /* warn */ case _: Array[Array[List[String]]] => () + ^ +unchecked3.scala:50: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure + /* warn */ case _: Array[List[String]] => () + ^ +unchecked3.scala:53: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure + /* warn */ case _: Array[Array[List[String]]] => () + ^ +unchecked3.scala:60: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure + /* warn */ case _: Array[List[String]] => () + ^ +unchecked3.scala:62: error: non-variable type argument Array[String] in type pattern Array[List[Array[String]]] is unchecked since it is eliminated by erasure + /* warn */ case _: Array[List[Array[String]]] => () + ^ +unchecked3.scala:63: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure + /* warn */ case _: Array[Array[List[String]]] => () + ^ +unchecked3.scala:75: error: abstract type A in type pattern Set[Q.this.A] is unchecked since it is eliminated by erasure + /* warn */ case xs: Set[A] => xs.head + ^ +12 errors found diff --git a/test/files/neg/unchecked3.scala b/test/files/neg/unchecked3.scala index cf01acd4ee..7b8c13e8f8 100644 --- a/test/files/neg/unchecked3.scala +++ b/test/files/neg/unchecked3.scala @@ -31,3 +31,53 @@ object MiscUnchecked { /* nowarn */ def twotypes4[T](x: A2[T]) = x match { case _: B2[T, _] => true } /* warn */ def twotypes5[T](x: A2[T]) = x match { case _: B2[_, Int] => true } } + +object Arrays { + def f1(x: Any) = x match { + /* nowarn */ case _: Array[Int] => () + /* nowarn */ case _: Array[Boolean] => () + /* nowarn */ case _: Array[String] => () + /* warn */ case _: Array[List[String]] => () + /* nowarn */ case _: Array[Array[String]] => () + /* nowarn */ case _: Array[Array[Array[String]]] => () + /* warn */ case _: Array[Array[List[String]]] => () + } + + def f2(x: Array[_]) = x match { + /* nowarn */ case _: Array[Int] => () + /* nowarn */ case _: Array[Boolean] => () + /* nowarn */ case _: Array[String] => () + /* warn */ case _: Array[List[String]] => () + /* nowarn */ case _: Array[Array[String]] => () + /* nowarn */ case _: Array[Array[Array[String]]] => () + /* warn */ case _: Array[Array[List[String]]] => () + } + + def f3[T](x: Array[T]) = x match { + /* nowarn */ case _: Array[Int] => () + /* nowarn */ case _: Array[Boolean] => () + /* nowarn */ case _: Array[String] => () + /* warn */ case _: Array[List[String]] => () + /* nowarn */ case _: Array[Array[String]] => () + /* warn */ case _: Array[List[Array[String]]] => () + /* warn */ case _: Array[Array[List[String]]] => () + } +} + +object Matching { + class Q { + type A + type B <: A + + def f(xs: Traversable[B]) = xs match { + /* nowarn */ case xs: List[A] => xs.head + /* nowarn */ case xs: Seq[B] => xs.head + /* warn */ case xs: Set[A] => xs.head + } + def f2[T <: B](xs: Traversable[T]) = xs match { + /* nowarn */ case xs: List[B with T] => xs.head + /* nowarn */ case xs: Seq[A] => xs.head + /* nowarn */ case xs: Set[T] => xs.head + } + } +} |