Support calling methods annotated with PolymorphicSignature

#KT-14416 Fixed
 #KT-26165 Fixed
This commit is contained in:
Alexander Udalov
2018-11-12 17:38:42 +01:00
parent b940418604
commit a796f11934
18 changed files with 595 additions and 25 deletions
@@ -0,0 +1,23 @@
// !LANGUAGE: +PolymorphicSignature
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// 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
}