summaryrefslogtreecommitdiff
path: root/test/files/run
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
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')
-rw-r--r--test/files/run/t5830.check1
-rw-r--r--test/files/run/t5830.scala13
-rw-r--r--test/files/run/t6011c.scala2
3 files changed, 8 insertions, 8 deletions
diff --git a/test/files/run/t5830.check b/test/files/run/t5830.check
index 675387eb8e..9260854676 100644
--- a/test/files/run/t5830.check
+++ b/test/files/run/t5830.check
@@ -1,5 +1,6 @@
a with oef
a with oef
+a with oef
a
def with oef
def
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'
diff --git a/test/files/run/t6011c.scala b/test/files/run/t6011c.scala
index 0647e3f81a..96a685b9cf 100644
--- a/test/files/run/t6011c.scala
+++ b/test/files/run/t6011c.scala
@@ -6,7 +6,7 @@ object Test extends App {
// at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:50)
// at scala.tools.nsc.Global.abort(Global.scala:249)
// at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder$jcode$.emitSWITCH(GenASM.scala:1850)
- ((1: Byte): @unchecked @annotation.switch) match {
+ ((1: Byte): @unchecked) match {
case 1 => 2
case 1 => 3 // crash
}