diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-27 10:20:45 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-27 12:06:09 -0700 |
commit | 211c9620ba83de143ea4776f55a3e0c4de11d002 (patch) | |
tree | 512aee7cb40f51ff689b06c0224729bef56cb89f /test/files/neg | |
parent | 690e4892297cb6bd1cfb1b6266036969f6aa17fe (diff) | |
download | scala-211c9620ba83de143ea4776f55a3e0c4de11d002.tar.gz scala-211c9620ba83de143ea4776f55a3e0c4de11d002.tar.bz2 scala-211c9620ba83de143ea4776f55a3e0c4de11d002.zip |
Added logic and tests for unchecked refinements.
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/unchecked-refinement.check | 13 | ||||
-rw-r--r-- | test/files/neg/unchecked-refinement.flags | 1 | ||||
-rw-r--r-- | test/files/neg/unchecked-refinement.scala | 27 |
3 files changed, 41 insertions, 0 deletions
diff --git a/test/files/neg/unchecked-refinement.check b/test/files/neg/unchecked-refinement.check new file mode 100644 index 0000000000..d81517464f --- /dev/null +++ b/test/files/neg/unchecked-refinement.check @@ -0,0 +1,13 @@ +unchecked-refinement.scala:17: error: abstract type U in type pattern Foo[U,U,V] is unchecked since it is eliminated by erasure + /* warn */ case _: Foo[U, U, V] if b => () + ^ +unchecked-refinement.scala:19: error: non-variable type argument Any in type pattern Foo[Any,U,V] is unchecked since it is eliminated by erasure + /* warn */ case _: Foo[Any, U, V] if b => () + ^ +unchecked-refinement.scala:23: error: a pattern match on a refinement type is unchecked + /* nowarn - todo */ case x: AnyRef { def bippy: Int } if b => x.bippy // this could/should do an instance check and not warn + ^ +unchecked-refinement.scala:24: error: a pattern match on a refinement type is unchecked + /* nowarn - todo */ case x: AnyRef { def size: Int } if b => x.size // this could/should do a static conformance test and not warn + ^ +four errors found diff --git a/test/files/neg/unchecked-refinement.flags b/test/files/neg/unchecked-refinement.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/unchecked-refinement.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/unchecked-refinement.scala b/test/files/neg/unchecked-refinement.scala new file mode 100644 index 0000000000..79ed7f13c1 --- /dev/null +++ b/test/files/neg/unchecked-refinement.scala @@ -0,0 +1,27 @@ +// a.scala +// Thu Sep 27 09:42:16 PDT 2012 + +trait Bar[-T1, T2, +T3] { } +trait Foo[-T1, T2, +T3] extends Bar[T1, T2, T3] + +class A { + var b = true + + def f1(x: Foo[Int, Int, Int]) = x match { + /* nowarn */ case _: Foo[Nothing, Int, Any] => true + } + def f2[T, U, V](x: Foo[T, U, V]) = x match { + /* nowarn */ case _: Foo[Nothing, U, Any] => true + } + def f3[T, U, V](x: Foo[T, U, V]) = x match { + /* warn */ case _: Foo[U, U, V] if b => () + /* nowarn */ case _: Foo[Nothing, U, V] if b => () + /* warn */ case _: Foo[Any, U, V] if b => () + } + + def f4(xs: List[Int]) = xs match { + /* nowarn - todo */ case x: AnyRef { def bippy: Int } if b => x.bippy // this could/should do an instance check and not warn + /* nowarn - todo */ case x: AnyRef { def size: Int } if b => x.size // this could/should do a static conformance test and not warn + /* nowarn */ case x: ((AnyRef { def size: Int }) @unchecked) if b => x.size + } +} |