From ba325127141e70e3464be80fddc699e23b638a3d Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 24 Feb 2015 09:14:18 +0100 Subject: Test case for SI-9111 workaround. --- .../tools/nsc/backend/jvm/opt/InlinerTest.scala | 43 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'test/junit') 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 should be inlined: + |The method ()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) + } } -- cgit v1.2.3