Files
kotlin/compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFunction.kt
Alexander Udalov c5fc729297 Support inline classes in function signatures in call/callBy
#KT-25664 Fixed
 #KT-26748 Open
 #KT-26765 Open

(cherry picked from commit 3a5de13dd4)
2018-09-14 14:42:49 +03:00

36 lines
873 B
Kotlin
Vendored

// IGNORE_BACKEND: JS_IR, JS, NATIVE, JVM_IR
// JVM_TARGET: 1.8
// WITH_REFLECT
import kotlin.reflect.KFunction
import kotlin.test.assertEquals
inline class S(val value: String) {
operator fun plus(other: S): S = S(this.value + other.value)
}
object C {
@JvmStatic
fun foo(x: S, y: String): S = x + S(y)
}
interface I {
companion object {
@JvmStatic
fun bar(x: String, y: S): S = S(x) + y
}
}
fun box(): String {
assertEquals(S("ab"), C::foo.call(S("a"), "b"))
assertEquals(S("cd"), (I)::bar.call("c", S("d")))
val unboundFoo = C::class.members.single { it.name == "foo" } as KFunction<*>
assertEquals(S("ef"), unboundFoo.call(C, S("e"), "f"))
val unboundBar = I.Companion::class.members.single { it.name == "bar" } as KFunction<*>
assertEquals(S("gh"), unboundBar.call(I, "g", S("h")))
return "OK"
}