Fix regression in reflection on looking up equals/hashCode/toString in interface
Caused by4266e50be8and8ccbbf71ec. Previously it worked because we used hardcoded signatures of equals/hashCode/toString and always looked them up in java.lang.Object #KT-25404 Fixed
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.memberFunctions
|
||||
import kotlin.reflect.jvm.javaMethod
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
annotation class A
|
||||
interface I
|
||||
class C
|
||||
|
||||
interface MyCustomMembers {
|
||||
fun equals(): Boolean
|
||||
fun hashCode(hehe: Int): Int
|
||||
fun toString(hehe: String): Any
|
||||
}
|
||||
|
||||
interface MyCloneable : Cloneable
|
||||
|
||||
fun KClass<*>.functions() = memberFunctions.map { it.javaMethod!!.name }.sorted()
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf("equals", "hashCode", "toString"), A::class.functions())
|
||||
assertEquals(listOf("equals", "hashCode", "toString"), I::class.functions())
|
||||
assertEquals(listOf("equals", "hashCode", "toString"), C::class.functions())
|
||||
|
||||
assertEquals(
|
||||
listOf("equals", "equals", "hashCode", "hashCode", "toString", "toString"),
|
||||
MyCustomMembers::class.functions()
|
||||
)
|
||||
|
||||
// TODO: KT-22923
|
||||
// assertEquals(listOf("clone", "equals", "hashCode", "toString"), MyCloneable::class.functions())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user