From bc719cb8e4957a80e423350d8e993f1fa6a2a997 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 21 Jul 2012 19:49:55 -0700 Subject: 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. --- test/files/pos/unchecked-a.flags | 1 + test/files/pos/unchecked-a.scala | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/files/pos/unchecked-a.flags create mode 100644 test/files/pos/unchecked-a.scala (limited to 'test/files/pos') diff --git a/test/files/pos/unchecked-a.flags b/test/files/pos/unchecked-a.flags new file mode 100644 index 0000000000..779916d58f --- /dev/null +++ b/test/files/pos/unchecked-a.flags @@ -0,0 +1 @@ +-unchecked -Xfatal-warnings \ No newline at end of file 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} +} -- cgit v1.2.3