diff options
author | Paul Phillips <paulp@improving.org> | 2012-07-21 19:49:55 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-07-27 05:42:17 -0700 |
commit | bc719cb8e4957a80e423350d8e993f1fa6a2a997 (patch) | |
tree | 2939e8688721c66fd1493bdadf9260d75faa4514 /test/files/pos/unchecked-a.scala | |
parent | ad08f24448729009fc8d5ff0acf307a43b4cfe0a (diff) | |
download | scala-bc719cb8e4957a80e423350d8e993f1fa6a2a997.tar.gz scala-bc719cb8e4957a80e423350d8e993f1fa6a2a997.tar.bz2 scala-bc719cb8e4957a80e423350d8e993f1fa6a2a997.zip |
Improve unchecked warnings a lot.
Don't warn on "uncheckable" type patterns if they can be
statically guaranteed, regardless of their runtime checkability.
This covers patterns like Seq[Any] and lots more.
Review by @adriaanm.
Diffstat (limited to 'test/files/pos/unchecked-a.scala')
-rw-r--r-- | test/files/pos/unchecked-a.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/files/pos/unchecked-a.scala b/test/files/pos/unchecked-a.scala new file mode 100644 index 0000000000..deceb91c36 --- /dev/null +++ b/test/files/pos/unchecked-a.scala @@ -0,0 +1,15 @@ +trait Y +trait Z extends Y +class X[+A <: Y] + +object Test { + def f1(x: X[_ <: Y]) = x match { + case _: X[Any] => // looks a little funny; `Any` is outside the bounds for `A` + } + def f2(x: X[_ <: Y]) = x match { + case _: X[Y] => // looks better, let's allow this (too) + } + + // NonLocalReturnControl[_] warnings + def foo: Int = List(0).foldLeft(0){case _ => return 0} +} |