From 0c25979244877b4431066700a6e945f145771c3c Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Mon, 29 Sep 2014 17:52:40 +0200 Subject: SI-8731 warning if @switch is ignored For matches with two or fewer cases, @switch is ignored. This should not happen silently. --- test/files/neg/t8731.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/files/neg/t8731.scala (limited to 'test/files/neg/t8731.scala') diff --git a/test/files/neg/t8731.scala b/test/files/neg/t8731.scala new file mode 100644 index 0000000000..d93fe706ad --- /dev/null +++ b/test/files/neg/t8731.scala @@ -0,0 +1,15 @@ +class C { + // not a compile-time constant due to return type + final val K: Int = 20 + + def f(x: Int) = (x: @annotation.switch) match { + case K => 0 + case 2 => 1 + } + + def g(x: Int) = (x: @annotation.switch) match { + case K => 0 + case 2 => 1 + case 3 => 2 + } +} -- cgit v1.2.3