summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-05 01:58:12 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-07-05 01:58:12 -0700
commit171a1d8bc859947d80d4728c251abe330dbe9802 (patch)
treea51d9082b22e5b06a16c668a9d84a2d6f52800fd /test/files/neg
parentb22cebda71b003a6083730a40b514a321f4ff1a5 (diff)
parent64acb46ab796a01bb5186385b7f8568748a857be (diff)
downloadscala-171a1d8bc859947d80d4728c251abe330dbe9802.tar.gz
scala-171a1d8bc859947d80d4728c251abe330dbe9802.tar.bz2
scala-171a1d8bc859947d80d4728c251abe330dbe9802.zip
Merge pull request #821 from adriaanm/64acb46ab7
SI-5830 switches: support guards, unreachability
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/switch.check5
-rw-r--r--test/files/neg/switch.scala4
-rw-r--r--test/files/neg/t5830.check4
-rw-r--r--test/files/neg/t5830.flags1
-rw-r--r--test/files/neg/t5830.scala9
5 files changed, 17 insertions, 6 deletions
diff --git a/test/files/neg/switch.check b/test/files/neg/switch.check
index 8955c94b32..e4730b6459 100644
--- a/test/files/neg/switch.check
+++ b/test/files/neg/switch.check
@@ -1,10 +1,7 @@
-switch.scala:28: error: could not emit switch for @switch annotated match
- def fail1(c: Char) = (c: @switch) match {
- ^
switch.scala:38: error: could not emit switch for @switch annotated match
def fail2(c: Char) = (c: @switch @unchecked) match {
^
switch.scala:45: error: could not emit switch for @switch annotated match
def fail3(c: Char) = (c: @unchecked @switch) match {
^
-three errors found
+two errors found
diff --git a/test/files/neg/switch.scala b/test/files/neg/switch.scala
index a3dfd869d6..198583fe41 100644
--- a/test/files/neg/switch.scala
+++ b/test/files/neg/switch.scala
@@ -24,8 +24,8 @@ object Main {
case _ => false
}
- // has a guard
- def fail1(c: Char) = (c: @switch) match {
+ // has a guard, but since SI-5830 that's ok
+ def succ_guard(c: Char) = (c: @switch) match {
case 'A' | 'B' | 'C' => true
case x if x == 'A' => true
case _ => false
diff --git a/test/files/neg/t5830.check b/test/files/neg/t5830.check
new file mode 100644
index 0000000000..85cb84378f
--- /dev/null
+++ b/test/files/neg/t5830.check
@@ -0,0 +1,4 @@
+t5830.scala:6: error: unreachable code
+ case 'a' => println("b") // unreachable
+ ^
+one error found
diff --git a/test/files/neg/t5830.flags b/test/files/neg/t5830.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/t5830.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t5830.scala b/test/files/neg/t5830.scala
new file mode 100644
index 0000000000..c2df3dec8b
--- /dev/null
+++ b/test/files/neg/t5830.scala
@@ -0,0 +1,9 @@
+import scala.annotation.switch
+
+class Test {
+ def unreachable(ch: Char) = (ch: @switch) match {
+ case 'a' => println("b") // ok
+ case 'a' => println("b") // unreachable
+ case 'c' =>
+ }
+} \ No newline at end of file