Support JVM polymorphic signature calls to methods with void return type
#KT-32026 Fixed
This commit is contained in:
@@ -47,5 +47,16 @@ fun box(): String {
|
||||
val r8 = mh.invoke(arrayOf(args))
|
||||
if (r8 !is Array<*> || !r8.contentEquals(args)) return "Fail 8: $r8"
|
||||
|
||||
// The next two calls check behavior in a statement context (where the call result is not used)
|
||||
|
||||
try {
|
||||
mh.invokeExact(args)
|
||||
return "Fail 9"
|
||||
} catch (e: WrongMethodTypeException) {
|
||||
// OK
|
||||
}
|
||||
|
||||
mh.invoke(args)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -PolymorphicSignature
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// FULL_JDK
|
||||
@@ -44,5 +45,11 @@ fun box(): String {
|
||||
val r8 = mh.invoke(arrayOf(args))
|
||||
if (r8 !is Array<*> || r8[0] !is Array<*> || !(r8[0] as Array<*>).contentEquals(args)) return "Fail 8: $r8"
|
||||
|
||||
// The next two calls check behavior in a statement context (where the call result is not used)
|
||||
|
||||
mh.invokeExact(args)
|
||||
|
||||
mh.invoke(args)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// !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 state = "Fail"
|
||||
|
||||
class C {
|
||||
fun foo(s: String) {
|
||||
state = s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val mh = MethodHandles.lookup().findVirtual(
|
||||
C::class.java, "foo",
|
||||
MethodType.methodType(Void.TYPE, String::class.java)
|
||||
)
|
||||
|
||||
mh.invokeExact(C(), "OK")
|
||||
|
||||
return state
|
||||
}
|
||||
Reference in New Issue
Block a user