aboutsummaryrefslogtreecommitdiff
path: root/tests/untried/neg/t6011.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/untried/neg/t6011.scala')
-rw-r--r--tests/untried/neg/t6011.scala23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/untried/neg/t6011.scala b/tests/untried/neg/t6011.scala
new file mode 100644
index 000000000..31a9f99a2
--- /dev/null
+++ b/tests/untried/neg/t6011.scala
@@ -0,0 +1,23 @@
+object Test {
+ def f(ch: Char): Any = ch match {
+ case 'a' => 1
+ case 'a' | 'c' => 1 // unreachable
+ }
+
+ // won't be compiled to a switch since it has an unreachable (duplicate) case
+ def f2(ch: Char): Any = (ch: @annotation.switch) match {
+ case 'a' | 'b' => 1
+ case 'b' | 'a' => 1 // unreachable
+ case _ =>
+ }
+
+ // s'all good
+ def f3(ch: Char): Any = (ch: @annotation.switch) match {
+ case 'a' | 'b' if (true: Boolean) => 1
+ case 'b' | 'a' => 1 // ok
+ case _ => // need third case to check switch annotation (two-case switches are always okay to compile to if-then-else)
+ }
+
+
+ def main(args: Array[String]): Unit = f('a')
+}