JVM IR: unmute boxInline tests on enclosing method/class

In box tests, only check that Java reflection does not crash on the
EnclosingMethod attribute generated in these classes. If it doesn't
crash, most likely it returns the value that can be read from the class
file by ASM, which is what the newly added bytecode listing tests are
checking now.
This commit is contained in:
Alexander Udalov
2020-09-01 21:52:58 +02:00
parent 985088a3f1
commit 0dea6b94c6
18 changed files with 719 additions and 63 deletions
@@ -1,50 +1,43 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: 1.kt
// WITH_REFLECT
package test
interface Z {
fun a() : String
fun a(): String
}
inline fun test(crossinline z: () -> String) =
object : Z {
object : Z {
val p = z()
val p = z()
override fun a() = p
}
override fun a() = p
}
inline fun<T> call(crossinline z: () -> T) = z()
inline fun <T> call(crossinline z: () -> T) = z()
// FILE: 2.kt
import test.*
fun box(): String {
/*This captured parameter would be added to object constructor*/
val captured = "OK";
// This captured parameter would be added to object constructor
val captured = "OK"
var z: Any = "fail"
val res = test {
call {
z = {
captured
}
}
(z as Function0<String>)()
}
val enclosingConstructor = z.javaClass.enclosingConstructor
if (enclosingConstructor?.name != "_2Kt\$box$\$inlined\$test$1") return "fail 1: ${enclosingConstructor?.name}"
val enclosingClass = z.javaClass.enclosingClass
if (enclosingClass?.name != "_2Kt\$box$\$inlined\$test$1") return "fail 2: ${enclosingClass?.name}"
// Check that Java reflection doesn't crash. Actual values are tested in bytecodeListing/inline/enclosingInfo/.
z.javaClass.enclosingConstructor
z.javaClass.enclosingMethod
z.javaClass.enclosingClass
return res.a()
}