From ec8436306eba91635d022707166c1541e68ffb2c Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Mon, 9 Nov 2015 14:26:54 +0100 Subject: Rewrite test: no local for underscore --- .../nsc/transform/patmat/PatmatBytecodeTest.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/junit') 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, "", ASTORE /*1*/, + ALOAD /*1*/, "y", ASTORE /*2*/, + ALOAD /*1*/, "x", INSTANCEOF, IFNE /*R*/, + NEW, DUP, ALOAD /*1*/, "", ATHROW, + /*R*/ -1, ALOAD /*2*/, ARETURN)) + } } -- cgit v1.2.3