diff options
Diffstat (limited to 'test/files/neg/t6011.scala')
-rw-r--r-- | test/files/neg/t6011.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/files/neg/t6011.scala b/test/files/neg/t6011.scala new file mode 100644 index 0000000000..a36cca7897 --- /dev/null +++ b/test/files/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') +}
\ No newline at end of file |