Files
kotlin/compiler/testData/codegen/box/polymorphicSignature/invokeExactWithInlineClass.kt
2019-12-03 08:31:46 +01:00

24 lines
562 B
Kotlin
Vendored

// !LANGUAGE: +PolymorphicSignature
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// FULL_JDK
// SKIP_JDK6
// WITH_REFLECT
import java.lang.invoke.MethodHandles
import kotlin.reflect.jvm.javaMethod
inline class Z(val s: String)
fun foo(z: Z): String = z.s
fun box(): String {
val mh = MethodHandles.lookup().unreflect(::foo.javaMethod!!)
// TODO: it's unclear whether this should throw or not, see KT-28214.
val r1 = mh.invokeExact(Z("OK")) as String
if (r1 != "OK") return "Fail r1: $r1"
return mh.invokeExact("OK") as String
}