Files
kotlin-fork/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.kt
T
Alexander Udalov 0dea6b94c6 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.
2020-09-07 19:41:37 +02:00

44 lines
826 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: 1.kt
package test
interface Z {
fun a(): String
}
inline fun test(crossinline z: () -> String) =
object : Z {
val p = z()
override fun a() = p
}
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"
var z: Any = "fail"
val res = test {
call {
z = {
captured
}
}
(z as Function0<String>)()
}
// 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()
}