diff options
Diffstat (limited to 'test/junit')
-rw-r--r-- | test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala index e78b5071e0..5f7a6d0633 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlineWarningTest.scala @@ -31,7 +31,8 @@ object InlineWarningTest extends ClearAfterClass.Clearable { val argsNoWarn = "-Ybackend:GenBCode -Yopt:l:classpath" val args = argsNoWarn + " -Yopt-warnings" var compiler = newCompiler(extraArgs = args) - def clear(): Unit = { compiler = null } + var compilerWarnAll = newCompiler(extraArgs = argsNoWarn + " -Yopt-warnings:_") + def clear(): Unit = { compiler = null; compilerWarnAll = null } } @RunWith(classOf[JUnit4]) @@ -39,8 +40,9 @@ class InlineWarningTest extends ClearAfterClass { ClearAfterClass.stateToClear = InlineWarningTest val compiler = InlineWarningTest.compiler + val compilerWarnAll = InlineWarningTest.compilerWarnAll - def compile(scalaCode: String, javaCode: List[(String, String)] = Nil, allowMessage: StoreReporter#Info => Boolean = _ => false): List[ClassNode] = { + def compile(scalaCode: String, javaCode: List[(String, String)] = Nil, allowMessage: StoreReporter#Info => Boolean = _ => false, compiler: Global = compiler): List[ClassNode] = { compileClasses(compiler)(scalaCode, javaCode, allowMessage) } @@ -171,6 +173,33 @@ class InlineWarningTest extends ClearAfterClass { } @Test + def dontWarnWhenNotIlnineAnnotated(): Unit = { + val code = + """class M { + | final def f(t: Int => Int) = { + | @noinline def nested = 0 + | nested + t(1) + | } + | def t = f(x => x + 1) + |} + | + |class N { + | def t(a: M) = a.f(x => x + 1) + |} + """.stripMargin + compile(code, allowMessage = _ => false) // no warnings allowed + + val warn = + """M::f(Lscala/Function1;)I could not be inlined: + |The callee M::f(Lscala/Function1;)I contains the instruction INVOKESPECIAL M.nested$1 ()I + |that would cause an IllegalAccessError when inlined into class N""".stripMargin + + var c = 0 + compile(code, compiler = compilerWarnAll, allowMessage = i => { c += 1; i.msg contains warn }) + assert(c == 1, c) + } + + @Test def cannotMixStrictfp(): Unit = { val code = """import annotation.strictfp |