summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala28
-rw-r--r--test/pending/pos/sealed-final.flags41
-rw-r--r--test/pending/pos/sealed-final.scala14
4 files changed, 29 insertions, 56 deletions
diff --git a/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala b/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala
index 69c3f69380..342f403426 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala
@@ -48,7 +48,7 @@ object CodeGenTools {
resetOutput(compiler)
compiler
}
-
+
def newCompilerWithoutVirtualOutdir(defaultArgs: String = "-usejavacp", extraArgs: String = ""): Global = {
val settings = new Settings()
val args = (CommandLineParser tokenize defaultArgs) ++ (CommandLineParser tokenize extraArgs)
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
index 192a036d5b..77133255f4 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
@@ -1468,4 +1468,32 @@ class InlinerTest extends ClearAfterClass {
assertEquals(casts("t5"), Nil)
assertEquals(casts("t6"), Nil)
}
+
+ @Test
+ def inlineFromSealed(): Unit = {
+ val code =
+ """sealed abstract class Foo {
+ | @inline def bar(x: Int) = x + 1
+ |}
+ |object Foo {
+ | def mkFoo(): Foo = new Baz2
+ |}
+ |
+ |object Baz1 extends Foo
+ |final class Baz2 extends Foo
+ |
+ |object Test {
+ | def f = Foo.mkFoo() bar 10
+ |}
+ """.stripMargin
+
+ val cls = compile(code)
+ val test = cls.find(_.name == "Test$").get
+ assertEquals(
+ getSingleMethod(test, "f").instructions.summary,
+ List(GETSTATIC, "mkFoo",
+ BIPUSH, ISTORE,
+ IFNONNULL, ACONST_NULL, ATHROW, -1 /*label*/,
+ ILOAD, ICONST_1, IADD, IRETURN))
+ }
}
diff --git a/test/pending/pos/sealed-final.flags b/test/pending/pos/sealed-final.flags
deleted file mode 100644
index 63d024a0ba..0000000000
--- a/test/pending/pos/sealed-final.flags
+++ /dev/null
@@ -1,41 +0,0 @@
--Xfatal-warnings -Yinline-warnings -Ybackend:GenASM -optimise
-/*
-The new flag settings could be
- -Yopt-warnings -Yopt:l:project
-
-The issue here is that things are being inlined, but a lot of
-redundant load/store instructions are left behind:
-
-2.11.7:
-
- public int f();
- Code:
- 0: getstatic #19 // Field Foo$.MODULE$:LFoo$;
- 3: invokevirtual #23 // Method Foo$.mkFoo:()LFoo;
- 6: pop
- 7: bipush 10
- 9: iconst_1
- 10: iadd
- 11: ireturn
-
-
-2.12.0-M3:
-
- public int f();
- Code:
- 0: getstatic #19 // Field Foo$.MODULE$:LFoo$;
- 3: invokevirtual #23 // Method Foo$.mkFoo:()LFoo;
- 6: bipush 10
- 8: istore_2
- 9: dup
- 10: ifnonnull 15
- 13: aconst_null
- 14: athrow
- 15: astore_1
- 16: iload_2
- 17: iconst_1
- 18: iadd
- 19: istore_3
- 20: iload_3
- 21: ireturn
-*/ \ No newline at end of file
diff --git a/test/pending/pos/sealed-final.scala b/test/pending/pos/sealed-final.scala
deleted file mode 100644
index bdedb5c1f6..0000000000
--- a/test/pending/pos/sealed-final.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-sealed abstract class Foo {
- @inline def bar(x: Int) = x + 1
-}
-object Foo {
- def mkFoo(): Foo = new Baz2
-}
-
-object Baz1 extends Foo
-final class Baz2 extends Foo
-
-object Test {
- // bar should be inlined now
- def f = Foo.mkFoo() bar 10
-}