summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-18 20:00:44 +0200
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-07-18 20:14:55 +0200
commit86f7bc35e5fd9c12913318ed2b31e207d6f261fb (patch)
tree6331f1b1b1ee5e12408a443edfe630fa682adfae
parenta4b7928c55c362ce489ae9ba480d2b31844ce0f1 (diff)
downloadscala-86f7bc35e5fd9c12913318ed2b31e207d6f261fb.tar.gz
scala-86f7bc35e5fd9c12913318ed2b31e207d6f261fb.tar.bz2
scala-86f7bc35e5fd9c12913318ed2b31e207d6f261fb.zip
SI-6104 support This pattern
This(name) is treated just like Ident(name) apparently this pattern was used in 2.9 code, though I'm not sure it's spec'ed
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala4
-rw-r--r--test/files/run/t6104.check1
-rw-r--r--test/files/run/t6104.scala8
3 files changed, 11 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
index 4e4176e531..4c4115a561 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
@@ -413,7 +413,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
The pattern matches any value v such that r == v (ยง12.1).
The type of r must conform to the expected type of the pattern.
**/
- case Literal(Constant(_)) | Ident(_) | Select(_, _) =>
+ case Literal(Constant(_)) | Ident(_) | Select(_, _) | This(_) =>
noFurtherSubPats(EqualityTestTreeMaker(patBinder, patTree, pos))
case Alternative(alts) =>
@@ -430,7 +430,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
patmatDebug("WARNING: Bind tree with unbound symbol "+ patTree)
noFurtherSubPats() // there's no symbol -- something's wrong... don't fail here though (or should we?)
- // case Star(_) | ArrayValue | This => error("stone age pattern relics encountered!")
+ // case Star(_) | ArrayValue => error("stone age pattern relics encountered!")
case _ =>
error("unsupported pattern: "+ patTree +"(a "+ patTree.getClass +")")
diff --git a/test/files/run/t6104.check b/test/files/run/t6104.check
new file mode 100644
index 0000000000..9766475a41
--- /dev/null
+++ b/test/files/run/t6104.check
@@ -0,0 +1 @@
+ok
diff --git a/test/files/run/t6104.scala b/test/files/run/t6104.scala
new file mode 100644
index 0000000000..8ab12c7752
--- /dev/null
+++ b/test/files/run/t6104.scala
@@ -0,0 +1,8 @@
+class A { Self =>
+ val ok = "ok"
+ this match {
+ case me@Self => println(me.ok)
+ }
+}
+
+object Test extends A with App \ No newline at end of file