[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
@@ -53,7 +53,7 @@ internal class KFunctionImpl private constructor(
descriptor
)
override val isBound: Boolean get() = rawBoundReceiver != CallableReference.NO_RECEIVER
override val isBound: Boolean get() = rawBoundReceiver !== CallableReference.NO_RECEIVER
override val descriptor: FunctionDescriptor by ReflectProperties.lazySoft(descriptorInitialValue) {
container.findFunctionDescriptor(name, signature)
@@ -47,7 +47,7 @@ internal abstract class KPropertyImpl<out V> private constructor(
val boundReceiver
get() = rawBoundReceiver.coerceToExpectedReceiverType(descriptor)
override val isBound: Boolean get() = rawBoundReceiver != CallableReference.NO_RECEIVER
override val isBound: Boolean get() = rawBoundReceiver !== CallableReference.NO_RECEIVER
private val _javaField = lazy(PUBLICATION) {
when (val jvmSignature = RuntimeTypeMapper.mapPropertySignature(descriptor)) {