summaryrefslogtreecommitdiff
path: root/test/files/run/t5830.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2014-09-29 17:52:40 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2014-10-06 20:56:32 +0200
commit0c25979244877b4431066700a6e945f145771c3c (patch)
tree92d631fc91e90c55508eda2b4aa460c2ba29658c /test/files/run/t5830.scala
parenta52db7f1639c6d48eaa64ae609385a60467fd566 (diff)
downloadscala-0c25979244877b4431066700a6e945f145771c3c.tar.gz
scala-0c25979244877b4431066700a6e945f145771c3c.tar.bz2
scala-0c25979244877b4431066700a6e945f145771c3c.zip
SI-8731 warning if @switch is ignored
For matches with two or fewer cases, @switch is ignored. This should not happen silently.
Diffstat (limited to 'test/files/run/t5830.scala')
-rw-r--r--test/files/run/t5830.scala13
1 files changed, 6 insertions, 7 deletions
diff --git a/test/files/run/t5830.scala b/test/files/run/t5830.scala
index 5d808bfa28..03b9c540e0 100644
--- a/test/files/run/t5830.scala
+++ b/test/files/run/t5830.scala
@@ -1,12 +1,11 @@
import scala.annotation.switch
object Test extends App {
- // TODO: should not emit a switch
- // def noSwitch(ch: Char, eof: Boolean) = (ch: @switch) match {
- // case 'a' if eof => println("a with oef") // then branch
- // }
+ def noSwitch(ch: Char, eof: Boolean) = ch match {
+ case 'a' if eof => println("a with oef") // then branch
+ }
- def onlyThen(ch: Char, eof: Boolean) = (ch: @switch) match {
+ def onlyThen(ch: Char, eof: Boolean) = ch match {
case 'a' if eof => println("a with oef") // then branch
case 'c' =>
}
@@ -18,7 +17,7 @@ object Test extends App {
case 'c' =>
}
- def defaultUnguarded(ch: Char, eof: Boolean) = (ch: @switch) match {
+ def defaultUnguarded(ch: Char, eof: Boolean) = ch match {
case ' ' if eof => println("spacey oef")
case _ => println("default")
}
@@ -44,7 +43,7 @@ object Test extends App {
// case 'c' =>
// }
- // noSwitch('a', true)
+ noSwitch('a', true)
onlyThen('a', true) // 'a with oef'
ifThenElse('a', true) // 'a with oef'
ifThenElse('a', false) // 'a'