diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-25 18:14:49 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-25 18:21:42 -0700 |
commit | 9904301752c2aa8c8509f1bcd6108f626220524a (patch) | |
tree | 2c970440d0cd6e070f3d0ae1ffd961020330755a /test/files/neg/unchecked3.scala | |
parent | 9d423c9bb76dddcd080d98f4a05c02856708fc06 (diff) | |
download | scala-9904301752c2aa8c8509f1bcd6108f626220524a.tar.gz scala-9904301752c2aa8c8509f1bcd6108f626220524a.tar.bz2 scala-9904301752c2aa8c8509f1bcd6108f626220524a.zip |
Additional new tests for unchecked warnings.
Diffstat (limited to 'test/files/neg/unchecked3.scala')
-rw-r--r-- | test/files/neg/unchecked3.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/files/neg/unchecked3.scala b/test/files/neg/unchecked3.scala new file mode 100644 index 0000000000..cf01acd4ee --- /dev/null +++ b/test/files/neg/unchecked3.scala @@ -0,0 +1,33 @@ +sealed trait A2[T1] +final class B2[T1, T2] extends A2[T1] + +sealed trait A[T] +final class B[T] extends A[T] + +sealed trait A1[T] +trait B1[T] extends A1[T] +trait C1[T] extends A1[T] +trait D1[T] extends A1[Int] +trait E1[T] extends B1[Int] +trait F1[T] extends B1[T] + +object MiscUnchecked { + /* nowarn */ def knownType1(x: A[Int]) = x match { case _: B[Int] if true => 1 } + /* nowarn */ def knownType2(x: B[Int]) = x match { case _: A[Int] if true => 1 } + /* nowarn */ def tparamLeakage1(x: Any) = x match { case Array() => 1 } + /* nowarn */ def tparamLeakage2(x: Any) = x match { case List() => 1 } + + // E1[Double] implies B1[Int], but B1[Int] does not imply E1[Double], even if .isInstanceOf[E1[_]] + // F1[Int] implies B1[Int], and B1[Int] implies F1[Int] + + /* nowarn */ def peerTypes1(x: B1[Int]) = x match { case _: C1[Int] => true } + /* warn */ def peerTypes2(x: B1[Int]) = x match { case _: E1[Double] => true } + /* warn */ def peerTypes3(x: B1[_]) = x match { case _: F1[Double] => true } + /* nowarn */ def peerTypes4(x: B1[Int]) = x match { case _: F1[Int] => true } + + /* warn */ def twotypes1[T](x: B2[T, Int]) = x match { case _: A2[Int] => true } + /* nowarn */ def twotypes2[T](x: B2[Int, T]) = x match { case _: A2[Int] => true } + /* nowarn */ def twotypes3(x: A2[Int]) = x match { case _: B2[Int, _] => true } + /* 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 } +} |