mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
24 lines
562 B
Kotlin
Vendored
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
|
|
}
|