summaryrefslogtreecommitdiff
path: root/test/junit/scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2016-11-29 14:00:46 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2016-11-29 14:46:07 +0100
commitde25e861249826658663a6d40f13b9b91d1146fc (patch)
tree96ef6ae3a85ab104ec964aa294139e1849c04704 /test/junit/scala
parentb02e3914b6dee6b7da1c3da1864343ccdce5ca3c (diff)
downloadscala-de25e861249826658663a6d40f13b9b91d1146fc.tar.gz
scala-de25e861249826658663a6d40f13b9b91d1146fc.tar.bz2
scala-de25e861249826658663a6d40f13b9b91d1146fc.zip
Don't exclude super calls to trait methods from inlining
In 8020cd6, the inliner was changed to make sure trait methods bodies are not duplicated into the static super accessors, and from there into mixin forwarders. The check for mixin forwarders was too wide. In `def t = super.m`, where `m` is a trait method annotated `@inline`, we want to inline `m`. Note that `super.m` is translated to an `invokestatic T.m$`. The current check incorrectly identifies `t` as a mixin forwarder, and skip inlining.
Diffstat (limited to 'test/junit/scala')
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala15
1 files changed, 15 insertions, 0 deletions
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 90a938be35..7be88816d5 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
@@ -1738,4 +1738,19 @@ class InlinerTest extends BytecodeTesting {
val List(a, c, t) = compile(code, allowMessage = _.msg contains warn)
assertInvoke(getMethod(c, "t"), "T", "m$")
}
+
+ @Test
+ def sd259d(): Unit = {
+ val code =
+ """trait T {
+ | @inline final def m = 1
+ |}
+ |class C extends T {
+ | def t = super.m // inline call to T.m$ here, we're not in the mixin forwarder C.m
+ |}
+ """.stripMargin
+ val List(c, t) = compileClasses(code)
+ assertNoInvoke(getMethod(c, "t"))
+ assertInvoke(getMethod(c, "m"), "T", "m$")
+ }
}