Prohibit callable references to object members
To be able to make them more useful in the future, i.e. bound to the object instance
This commit is contained in:
compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/companionObjectFunction.kt
Vendored
+2
-1
@@ -1,4 +1,5 @@
|
||||
import kotlin.jvm.JvmStatic as static
|
||||
import kotlin.reflect.KFunction
|
||||
import kotlin.reflect.jvm.*
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.failsWith
|
||||
@@ -10,7 +11,7 @@ class C {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val foo = C.Companion::foo
|
||||
val foo = C.Companion::class.members.single { it.name == "foo" } as KFunction<*>
|
||||
|
||||
val j = foo.javaMethod ?: return "Fail: no Java method found for C::foo"
|
||||
assertEquals(3, j.invoke(C, "abc"))
|
||||
|
||||
Vendored
+2
-1
@@ -1,4 +1,5 @@
|
||||
import kotlin.jvm.JvmStatic as static
|
||||
import kotlin.reflect.KFunction
|
||||
import kotlin.reflect.jvm.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -7,7 +8,7 @@ object O {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val foo = O::foo
|
||||
val foo = O::class.members.single { it.name == "foo" } as KFunction<*>
|
||||
|
||||
val j = foo.javaMethod ?: return "Fail: no Java method found for O::foo"
|
||||
assertEquals(3, j.invoke(null, "abc"))
|
||||
|
||||
Reference in New Issue
Block a user