Improve implementation of callable reference superclasses
Previously to use reflection on them, you had to wrap an already created object with a "Reflection.function" or "Reflection.propertyN" call, which the JVM back-end was doing. This was not optimal in several senses and current solution fixes that
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class A {
|
||||
fun foo() = "foo"
|
||||
val bar = "bar"
|
||||
}
|
||||
|
||||
fun checkEqual(x: Any, y: Any) {
|
||||
assertEquals(x, y)
|
||||
assertEquals(y, x)
|
||||
assertEquals(x.hashCode(), y.hashCode())
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
checkEqual(A::foo, A::class.members.single { it.name == "foo" })
|
||||
checkEqual(A::bar, A::class.members.single { it.name == "bar" })
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user