summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/t8044-b.check4
-rw-r--r--test/files/neg/t8044-b.scala4
-rw-r--r--test/files/neg/t8044.check4
-rw-r--r--test/files/neg/t8044.scala4
-rw-r--r--test/files/pos/t8044.scala15
5 files changed, 31 insertions, 0 deletions
diff --git a/test/files/neg/t8044-b.check b/test/files/neg/t8044-b.check
new file mode 100644
index 0000000000..4a93e9a772
--- /dev/null
+++ b/test/files/neg/t8044-b.check
@@ -0,0 +1,4 @@
+t8044-b.scala:3: error: Pattern variables must start with a lower-case letter. (SLS 8.1.1.)
+ def g = 42 match { case `Oops` : Int => } // must be varish
+ ^
+one error found
diff --git a/test/files/neg/t8044-b.scala b/test/files/neg/t8044-b.scala
new file mode 100644
index 0000000000..fb2e921ac9
--- /dev/null
+++ b/test/files/neg/t8044-b.scala
@@ -0,0 +1,4 @@
+
+trait T {
+ def g = 42 match { case `Oops` : Int => } // must be varish
+}
diff --git a/test/files/neg/t8044.check b/test/files/neg/t8044.check
new file mode 100644
index 0000000000..678bf8c700
--- /dev/null
+++ b/test/files/neg/t8044.check
@@ -0,0 +1,4 @@
+t8044.scala:3: error: not found: value _
+ def f = 42 match { case `_` : Int => `_` } // doesn't leak quoted underscore
+ ^
+one error found
diff --git a/test/files/neg/t8044.scala b/test/files/neg/t8044.scala
new file mode 100644
index 0000000000..930c30c5a5
--- /dev/null
+++ b/test/files/neg/t8044.scala
@@ -0,0 +1,4 @@
+
+trait T {
+ def f = 42 match { case `_` : Int => `_` } // doesn't leak quoted underscore
+}
diff --git a/test/files/pos/t8044.scala b/test/files/pos/t8044.scala
new file mode 100644
index 0000000000..2519a8306b
--- /dev/null
+++ b/test/files/pos/t8044.scala
@@ -0,0 +1,15 @@
+
+trait T {
+ def f = 42 match { case `x` @ _ => x }
+ def g = 42 match { case `type` @ _ => `type` }
+ def h = 42 match { case `type` : Int => `type` }
+ def i = (null: Any) match { case _: Int | _: String => 17 }
+
+ // arbitrary idents allowed in @ syntax
+ def j = "Fred" match { case Name @ (_: String) => Name }
+ def k = "Fred" match { case * @ (_: String) => * }
+
+ // also in sequence pattern
+ def m = List(1,2,3,4,5) match { case List(1, `Rest of them` @ _*) => `Rest of them` }
+
+}