summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-11-09 14:26:54 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2016-01-25 11:44:41 +0100
commitec8436306eba91635d022707166c1541e68ffb2c (patch)
treef79ddc3ad6d6801081e2b4ccbf6121be8ca947df /test/junit
parentf4a74f7eefb0521c0531f930ac8fd505953e0f50 (diff)
downloadscala-ec8436306eba91635d022707166c1541e68ffb2c.tar.gz
scala-ec8436306eba91635d022707166c1541e68ffb2c.tar.bz2
scala-ec8436306eba91635d022707166c1541e68ffb2c.zip
Rewrite test: no local for underscore
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
index 5aac1f4656..cef27b4d87 100644
--- a/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
+++ b/test/junit/scala/tools/nsc/transform/patmat/PatmatBytecodeTest.scala
@@ -115,4 +115,23 @@ class PatmatBytecodeTest extends ClearAfterClass {
val c = compileClasses(optCompiler)(code).head
assert(!getSingleMethod(c, "a").instructions.exists(i => i.opcode == IFNULL || i.opcode == IFNONNULL), textify(findAsmMethod(c, "a")))
}
+
+ @Test
+ def optNoLoacalForUnderscore(): Unit = {
+ val code =
+ """case class Foo(x: Any, y: String)
+ |class C {
+ | def a = Foo(1, "a") match {
+ | case Foo(_: String, y) => y
+ | }
+ |}
+ """.stripMargin
+ val c = compileClasses(optCompiler)(code).head
+ assertEquals(textify(findAsmMethod(c, "a")), getSingleMethod(c, "a").instructions.summary,
+ List(NEW, DUP, ICONST_1, "boxToInteger", LDC, "<init>", ASTORE /*1*/,
+ ALOAD /*1*/, "y", ASTORE /*2*/,
+ ALOAD /*1*/, "x", INSTANCEOF, IFNE /*R*/,
+ NEW, DUP, ALOAD /*1*/, "<init>", ATHROW,
+ /*R*/ -1, ALOAD /*2*/, ARETURN))
+ }
}