Proper equality comparison for bound callable references represented as reflection objects
(including references to property accessors).
This commit is contained in:
@@ -40,7 +40,7 @@ public abstract class CallableReference implements KCallable {
|
||||
private KCallable reflected;
|
||||
|
||||
protected final Object receiver$0;
|
||||
private static final Object NO_RECEIVER = new Object();
|
||||
public static final Object NO_RECEIVER = new Object();
|
||||
|
||||
public CallableReference() {
|
||||
this(NO_RECEIVER);
|
||||
@@ -52,6 +52,10 @@ public abstract class CallableReference implements KCallable {
|
||||
|
||||
protected abstract KCallable computeReflected();
|
||||
|
||||
public Object getBoundReceiver() {
|
||||
return receiver$0;
|
||||
}
|
||||
|
||||
public KCallable compute() {
|
||||
KCallable result = reflected;
|
||||
if (result == null) {
|
||||
|
||||
@@ -80,7 +80,7 @@ public class FunctionReference extends CallableReference implements FunctionImpl
|
||||
return getOwner().equals(other.getOwner()) &&
|
||||
getName().equals(other.getName()) &&
|
||||
getSignature().equals(other.getSignature()) &&
|
||||
Intrinsics.areEqual(receiver$0, other.receiver$0);
|
||||
Intrinsics.areEqual(getBoundReceiver(), other.getBoundReceiver());
|
||||
}
|
||||
if (obj instanceof KFunction) {
|
||||
return obj.equals(compute());
|
||||
|
||||
@@ -51,7 +51,7 @@ public abstract class PropertyReference extends CallableReference implements KPr
|
||||
return getOwner().equals(other.getOwner()) &&
|
||||
getName().equals(other.getName()) &&
|
||||
getSignature().equals(other.getSignature()) &&
|
||||
Intrinsics.areEqual(receiver$0, other.receiver$0);
|
||||
Intrinsics.areEqual(getBoundReceiver(), other.getBoundReceiver());
|
||||
}
|
||||
if (obj instanceof KProperty) {
|
||||
return obj.equals(compute());
|
||||
|
||||
Reference in New Issue
Block a user