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:
Alexander Udalov
2015-10-14 16:39:43 +03:00
parent 63dfe13c43
commit ced1edcf98
26 changed files with 122 additions and 218 deletions
@@ -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"))
@@ -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"))