Support mapping between Kotlin functions and JVM methods/constructors

This commit is contained in:
Alexander Udalov
2015-07-15 23:33:37 +03:00
parent 93656c93c1
commit 936bede8b1
14 changed files with 323 additions and 38 deletions

View File

@@ -0,0 +1,19 @@
import kotlin.reflect.*
import kotlin.reflect.jvm.*
import javaMethods as J
fun box(): String {
val f = J::f
val fm = f.javaMethod ?: return "Fail: no Method for f"
if (fm.invoke(J(), "abc") != "abc") return "Fail fm"
val ff = fm.kotlinFunction ?: return "Fail: no KFunction for fm"
if (f != ff) return "Fail f != ff"
val g = J::g
val gm = g.javaMethod ?: return "Fail: no Method for g"
if (gm.invoke(null, "ghi") != "ghi") return "Fail gm"
val gg = gm.kotlinFunction ?: return "Fail: no KFunction for gm"
if (g != gg) return "Fail g != gg"
return "OK"
}