[Reflection] Use reference equality to determine that a callable reference is bound

It helps to avoid problems when receiver object implements structural equals violating the equality contract

#KT-60709
This commit is contained in:
Evgeniy.Zhelenskiy
2023-07-26 09:35:07 +02:00
committed by Space Team
parent 64f90f685d
commit 291d52820c
10 changed files with 58 additions and 2 deletions
@@ -0,0 +1,15 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
class Eq {
override fun equals(other: Any?): Boolean = true
override fun toString(): String = "1"
val x: String get() = "2"
}
fun box(): String {
require(Eq()::toString.callBy(mapOf()) == "1")
require(Eq()::x.callBy(mapOf()) == "2")
return "OK"
}