diff options
author | Paul Phillips <paulp@improving.org> | 2012-10-02 10:37:13 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-10-04 16:08:31 -0700 |
commit | d7354838948be58b8045e1218a9c757d9b90df76 (patch) | |
tree | f034b77a430cb98fc6f5add55e645be28b0cf21e /test | |
parent | 1f99df2c66cb1933dd4db74aa872497a4e26975b (diff) | |
download | scala-d7354838948be58b8045e1218a9c757d9b90df76.tar.gz scala-d7354838948be58b8045e1218a9c757d9b90df76.tar.bz2 scala-d7354838948be58b8045e1218a9c757d9b90df76.zip |
Fix for spurious warning.
Eliminates spurious "catch block may intercept non-local return"
seen in recent builds of master. Unified some catch logic
in TreeInfo, and removed some which never worked.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/catch-all.check | 9 | ||||
-rw-r--r-- | test/files/neg/nonlocal-warning.check | 3 | ||||
-rw-r--r-- | test/files/neg/nonlocal-warning.scala | 11 |
3 files changed, 19 insertions, 4 deletions
diff --git a/test/files/neg/catch-all.check b/test/files/neg/catch-all.check index aaf51480c3..2d58dd99a8 100644 --- a/test/files/neg/catch-all.check +++ b/test/files/neg/catch-all.check @@ -1,10 +1,13 @@ -catch-all.scala:2: warning: This catches all Throwables. If this is really intended, use `case _ : Throwable` to clear this warning. +catch-all.scala:2: warning: This catches all Throwables, which often has undesirable consequences. +If intentional, use `case _ : Throwable` to clear this warning. try { "warn" } catch { case _ => } ^ -catch-all.scala:4: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. +catch-all.scala:4: warning: This catches all Throwables, which often has undesirable consequences. +If intentional, use `case x : Throwable` to clear this warning. try { "warn" } catch { case x => } ^ -catch-all.scala:6: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. +catch-all.scala:6: warning: This catches all Throwables, which often has undesirable consequences. +If intentional, use `case x : Throwable` to clear this warning. try { "warn" } catch { case _: RuntimeException => ; case x => } ^ error: No warnings can be incurred under -Xfatal-warnings. diff --git a/test/files/neg/nonlocal-warning.check b/test/files/neg/nonlocal-warning.check index 5202df655a..67b3b10095 100644 --- a/test/files/neg/nonlocal-warning.check +++ b/test/files/neg/nonlocal-warning.check @@ -1,4 +1,5 @@ -nonlocal-warning.scala:4: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. +nonlocal-warning.scala:4: warning: This catches all Throwables, which often has undesirable consequences. +If intentional, use `case x : Throwable` to clear this warning. catch { case x => 11 } ^ nonlocal-warning.scala:2: warning: catch block may intercept non-local return from method foo diff --git a/test/files/neg/nonlocal-warning.scala b/test/files/neg/nonlocal-warning.scala index cc98bd631a..f908a86302 100644 --- a/test/files/neg/nonlocal-warning.scala +++ b/test/files/neg/nonlocal-warning.scala @@ -4,4 +4,15 @@ class Foo { catch { case x => 11 } 22 } + + val pf: PartialFunction[Throwable, Unit] = { + case x if false => () + } + + def bar(l: List[Int]): Int = { + try l foreach { _ => return 5 } + catch pf + finally println() + 22 + } } |