mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 00:21:29 +00:00
Add a test on null (since null is a special case in the PolymorphicSignature spec), and a test on a call without assignment to a variable
29 lines
524 B
Kotlin
Vendored
29 lines
524 B
Kotlin
Vendored
// !LANGUAGE: +PolymorphicSignature
|
|
// TARGET_BACKEND: JVM
|
|
// IGNORE_BACKEND_FIR: JVM_IR
|
|
// FULL_JDK
|
|
// SKIP_JDK6
|
|
// WITH_RUNTIME
|
|
|
|
import java.lang.invoke.MethodHandles
|
|
import java.lang.invoke.MethodType
|
|
|
|
var result: String? = "Fail"
|
|
|
|
class C {
|
|
fun foo(s: Nothing?) {
|
|
result = s
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
val mh = MethodHandles.lookup().findVirtual(
|
|
C::class.java, "foo",
|
|
MethodType.methodType(Void.TYPE, Void::class.java)
|
|
)
|
|
|
|
mh.invokeExact(C(), null)
|
|
|
|
return result ?: "OK"
|
|
}
|