diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-06-30 09:13:05 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-06-30 09:13:05 +0200 |
commit | a3315cdcf6ca2714e563eb813b645e267ba2ea5a (patch) | |
tree | 1c8b36ad1385ef8a397b0752b2bc9fc08b9c3c52 /test | |
parent | cd1e6f94e92f2c8fc79aa3c76b1e3b813182e2d3 (diff) | |
download | scala-a3315cdcf6ca2714e563eb813b645e267ba2ea5a.tar.gz scala-a3315cdcf6ca2714e563eb813b645e267ba2ea5a.tar.bz2 scala-a3315cdcf6ca2714e563eb813b645e267ba2ea5a.zip |
SI-2807 Avoid catch all warning for Stable Id patterns
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/catch-all.check | 12 | ||||
-rw-r--r-- | test/files/neg/catch-all.scala | 30 |
2 files changed, 27 insertions, 15 deletions
diff --git a/test/files/neg/catch-all.check b/test/files/neg/catch-all.check index ab3d28777d..62f895cc7e 100644 --- a/test/files/neg/catch-all.check +++ b/test/files/neg/catch-all.check @@ -1,10 +1,10 @@ catch-all.scala:2: error: This catches all Throwables. If this is really intended, use `case _ : Throwable` to clear this warning. - try { "warn" } catch { case _ => } - ^ + try { "warn" } catch { case _ => } + ^ catch-all.scala:4: error: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. - try { "warn" } catch { case x => } - ^ + try { "warn" } catch { case x => } + ^ catch-all.scala:6: error: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. - try { "warn" } catch { case _: RuntimeException => ; case x => } - ^ + try { "warn" } catch { case _: RuntimeException => ; case x => } + ^ three errors found diff --git a/test/files/neg/catch-all.scala b/test/files/neg/catch-all.scala index 35a6d7af91..c05be77044 100644 --- a/test/files/neg/catch-all.scala +++ b/test/files/neg/catch-all.scala @@ -1,19 +1,31 @@ object CatchAll { - try { "warn" } catch { case _ => } + try { "warn" } catch { case _ => } - try { "warn" } catch { case x => } + try { "warn" } catch { case x => } - try { "warn" } catch { case _: RuntimeException => ; case x => } + try { "warn" } catch { case _: RuntimeException => ; case x => } - try { "okay" } catch { case _: Throwable => } + val t = T - try { "okay" } catch { case _: Exception => } + try { "okay" } catch { case T => } - try { "okay" } catch { case okay: Throwable => } + try { "okay" } catch { case `t` => } - try { "okay" } catch { case okay: Exception => } + try { "okay" } catch { case x @ T => } - try { "okay" } catch { case _ if "".isEmpty => } + try { "okay" } catch { case x @ `t` => } - "okay" match { case _ => "" } + try { "okay" } catch { case _: Throwable => } + + try { "okay" } catch { case _: Exception => } + + try { "okay" } catch { case okay: Throwable => } + + try { "okay" } catch { case okay: Exception => } + + try { "okay" } catch { case _ if "".isEmpty => } + + "okay" match { case _ => "" } } + +object T extends Throwable |