Support toString for AdaptedFunctionReference subclasses
Also make it serializable like other lambdas, suspend lambdas and normal callable references.
This commit is contained in:
@@ -8,6 +8,8 @@ package kotlin.jvm.internal;
|
||||
import kotlin.SinceKotlin;
|
||||
import kotlin.reflect.KDeclarationContainer;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import static kotlin.jvm.internal.CallableReference.NO_RECEIVER;
|
||||
|
||||
/**
|
||||
@@ -24,7 +26,7 @@ import static kotlin.jvm.internal.CallableReference.NO_RECEIVER;
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "WeakerAccess", "unused"})
|
||||
@SinceKotlin(version = "1.4")
|
||||
public class AdaptedFunctionReference {
|
||||
public class AdaptedFunctionReference implements FunctionBase, Serializable {
|
||||
protected final Object receiver;
|
||||
private final Class owner;
|
||||
private final String name;
|
||||
@@ -47,6 +49,11 @@ public class AdaptedFunctionReference {
|
||||
this.flags = flags >> 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArity() {
|
||||
return arity;
|
||||
}
|
||||
|
||||
public KDeclarationContainer getOwner() {
|
||||
return owner == null ? null :
|
||||
isTopLevel ? Reflection.getOrCreateKotlinPackage(owner) : Reflection.getOrCreateKotlinClass(owner);
|
||||
@@ -77,4 +84,9 @@ public class AdaptedFunctionReference {
|
||||
result = result * 31 + flags;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Reflection.renderLambdaToString(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user