summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/catch-all.check10
-rw-r--r--test/files/neg/catch-all.flags1
-rw-r--r--test/files/neg/catch-all.scala19
3 files changed, 30 insertions, 0 deletions
diff --git a/test/files/neg/catch-all.check b/test/files/neg/catch-all.check
new file mode 100644
index 0000000000..ab3d28777d
--- /dev/null
+++ b/test/files/neg/catch-all.check
@@ -0,0 +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 _ => }
+ ^
+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 => }
+ ^
+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 => }
+ ^
+three errors found
diff --git a/test/files/neg/catch-all.flags b/test/files/neg/catch-all.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/catch-all.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/catch-all.scala b/test/files/neg/catch-all.scala
new file mode 100644
index 0000000000..35a6d7af91
--- /dev/null
+++ b/test/files/neg/catch-all.scala
@@ -0,0 +1,19 @@
+object CatchAll {
+ try { "warn" } catch { case _ => }
+
+ try { "warn" } catch { case x => }
+
+ try { "warn" } catch { case _: RuntimeException => ; case x => }
+
+ 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 _ => "" }
+}