summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-02-24 09:14:18 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2015-03-11 15:18:23 -0700
commitba325127141e70e3464be80fddc699e23b638a3d (patch)
treea10e6dc1f5146f722d8e64840de1ffde21d37084
parent2d88143f37144f3db5a1d1d27806518bea13ba47 (diff)
downloadscala-ba325127141e70e3464be80fddc699e23b638a3d.tar.gz
scala-ba325127141e70e3464be80fddc699e23b638a3d.tar.bz2
scala-ba325127141e70e3464be80fddc699e23b638a3d.zip
Test case for SI-9111 workaround.
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala43
1 files changed, 42 insertions, 1 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 caaa65bf7e..0581bd24fe 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
@@ -29,7 +29,8 @@ import scala.collection.convert.decorateAsScala._
import scala.tools.testing.ClearAfterClass
object InlinerTest extends ClearAfterClass.Clearable {
- var compiler = newCompiler(extraArgs = "-Ybackend:GenBCode -Yopt:l:classpath -Yopt-warnings")
+ val args = "-Ybackend:GenBCode -Yopt:l:classpath -Yopt-warnings"
+ var compiler = newCompiler(extraArgs = args)
// allows inspecting the caches after a compilation run
def notPerRun: List[Clearable] = List(compiler.genBCode.bTypes.classBTypeFromInternalName, compiler.genBCode.bTypes.byteCodeRepository.classes, compiler.genBCode.bTypes.callGraph.callsites)
@@ -861,4 +862,44 @@ class InlinerTest extends ClearAfterClass {
assertInvoke(m6, "U", "h")
assertInvoke(m6, "U", "i")
}
+
+ @Test
+ def mixedNoCrashSI9111(): Unit = {
+ val javaCode =
+ """public final class A {
+ | public static final class T { }
+ | public static final class Inner {
+ | public static final class T { }
+ | public T newT() { return null; }
+ | }
+ |}
+ """.stripMargin
+
+ val scalaCode =
+ """class C {
+ | val i = new A.Inner()
+ |}
+ """.stripMargin
+
+ // We don't get to see the warning about SI-9111, because it is associated with the MethodInlineInfo
+ // of method newT, which is not actually used.
+ // The problem is: if we reference `newT` in the scalaCode, the scala code does not compile,
+ // because then SI-9111 triggers during type-checking class C, in the compiler frontend, and
+ // we don't even get to the backend.
+ // Nevertheless, the workaround for SI-9111 in BcodeAsmCommon.buildInlineInfoFromClassSymbol
+ // is still necessary, otherwise this test crashes.
+ // The warning below is the typical warning we get in mixed compilation.
+ val warn =
+ """failed to determine if <init> should be inlined:
+ |The method <init>()V could not be found in the class A$Inner or any of its parents.
+ |Note that the following parent classes could not be found on the classpath: A$Inner""".stripMargin
+
+ var c = 0
+
+ compileClasses(newCompiler(extraArgs = InlinerTest.args + " -Yopt-warnings:_"))(
+ scalaCode,
+ List((javaCode, "A.java")),
+ allowMessage = i => {c += 1; i.msg contains warn})
+ assert(c == 1, c)
+ }
}