@@ -29,7 +29,8 @@ import scala.collection.convert.decorateAsScala._
2929import scala .tools .testing .ClearAfterClass
3030
3131object InlinerTest extends ClearAfterClass .Clearable {
32- var compiler = newCompiler(extraArgs = " -Ybackend:GenBCode -Yopt:l:classpath -Yopt-warnings" )
32+ val args = " -Ybackend:GenBCode -Yopt:l:classpath -Yopt-warnings"
33+ var compiler = newCompiler(extraArgs = args)
3334
3435 // allows inspecting the caches after a compilation run
3536 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 {
861862 assertInvoke(m6, " U" , " h" )
862863 assertInvoke(m6, " U" , " i" )
863864 }
865+
866+ @ Test
867+ def mixedNoCrashSI9111 (): Unit = {
868+ val javaCode =
869+ """ public final class A {
870+ | public static final class T { }
871+ | public static final class Inner {
872+ | public static final class T { }
873+ | public T newT() { return null; }
874+ | }
875+ |}
876+ """ .stripMargin
877+
878+ val scalaCode =
879+ """ class C {
880+ | val i = new A.Inner()
881+ |}
882+ """ .stripMargin
883+
884+ // We don't get to see the warning about SI-9111, because it is associated with the MethodInlineInfo
885+ // of method newT, which is not actually used.
886+ // The problem is: if we reference `newT` in the scalaCode, the scala code does not compile,
887+ // because then SI-9111 triggers during type-checking class C, in the compiler frontend, and
888+ // we don't even get to the backend.
889+ // Nevertheless, the workaround for SI-9111 in BcodeAsmCommon.buildInlineInfoFromClassSymbol
890+ // is still necessary, otherwise this test crashes.
891+ // The warning below is the typical warning we get in mixed compilation.
892+ val warn =
893+ """ failed to determine if <init> should be inlined:
894+ |The method <init>()V could not be found in the class A$Inner or any of its parents.
895+ |Note that the following parent classes could not be found on the classpath: A$Inner""" .stripMargin
896+
897+ var c = 0
898+
899+ compileClasses(newCompiler(extraArgs = InlinerTest .args + " -Yopt-warnings:_" ))(
900+ scalaCode,
901+ List ((javaCode, " A.java" )),
902+ allowMessage = i => {c += 1 ; i.msg contains warn})
903+ assert(c == 1 , c)
904+ }
864905}
0 commit comments