Minor, drop deprecated KotlinBuiltIns.getExtensionFunction
This commit is contained in:
@@ -27,8 +27,8 @@ import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
|
||||
import org.jetbrains.kotlin.codegen.context.ClosureContext;
|
||||
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil;
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension;
|
||||
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter;
|
||||
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
@@ -281,7 +281,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
||||
|
||||
Type[] myParameterTypes = bridge.getArgumentTypes();
|
||||
|
||||
List<ParameterDescriptor> calleeParameters = CollectionsKt.<ParameterDescriptor>plus(
|
||||
List<ParameterDescriptor> calleeParameters = CollectionsKt.plus(
|
||||
org.jetbrains.kotlin.utils.CollectionsKt.<ParameterDescriptor>singletonOrEmptyList(funDescriptor.getExtensionReceiverParameter()),
|
||||
funDescriptor.getValueParameters()
|
||||
);
|
||||
@@ -450,12 +450,11 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FunctionDescriptor getErasedInvokeFunction(@NotNull FunctionDescriptor elementDescriptor) {
|
||||
int arity = elementDescriptor.getValueParameters().size();
|
||||
ClassDescriptor elementClass = elementDescriptor.getExtensionReceiverParameter() == null
|
||||
? DescriptorUtilsKt.getBuiltIns(elementDescriptor).getFunction(arity)
|
||||
: DescriptorUtilsKt.getBuiltIns(elementDescriptor).getExtensionFunction(arity);
|
||||
MemberScope scope = elementClass.getDefaultType().getMemberScope();
|
||||
public static FunctionDescriptor getErasedInvokeFunction(@NotNull FunctionDescriptor function) {
|
||||
ClassDescriptor functionClass = DescriptorUtilsKt.getBuiltIns(function).getFunction(
|
||||
function.getValueParameters().size() + (function.getExtensionReceiverParameter() != null ? 1 : 0)
|
||||
);
|
||||
MemberScope scope = functionClass.getDefaultType().getMemberScope();
|
||||
return scope.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,26 +408,11 @@ public abstract class KotlinBuiltIns {
|
||||
return "Function" + parameterCount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getExtensionFunctionName(int parameterCount) {
|
||||
return getFunctionName(parameterCount + 1);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getFunction(int parameterCount) {
|
||||
return getBuiltInClassByName(getFunctionName(parameterCount));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the descriptor representing the class kotlin.Function{parameterCount + 1}
|
||||
* @deprecated there are no ExtensionFunction classes anymore, use {@link #getFunction(int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public ClassDescriptor getExtensionFunction(int parameterCount) {
|
||||
return getBuiltInClassByName(getExtensionFunctionName((parameterCount)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getThrowable() {
|
||||
return getBuiltInClassByName("Throwable");
|
||||
|
||||
+1
-7
@@ -74,13 +74,7 @@ public class MemberMatching {
|
||||
|
||||
@Override
|
||||
public String visitFunctionType(@NotNull KtFunctionType type, Void data) {
|
||||
int parameterCount = type.getParameters().size();
|
||||
if (type.getReceiverTypeReference() != null) {
|
||||
return KotlinBuiltIns.getExtensionFunctionName(parameterCount);
|
||||
}
|
||||
else {
|
||||
return KotlinBuiltIns.getFunctionName(parameterCount);
|
||||
}
|
||||
return KotlinBuiltIns.getFunctionName(type.getParameters().size() + (type.getReceiverTypeReference() != null ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-9
@@ -165,15 +165,14 @@ object InvokeIntrinsic : FunctionCallCase() {
|
||||
val callableDescriptor = callInfo.callableDescriptor
|
||||
if (callableDescriptor.name != OperatorNameConventions.INVOKE)
|
||||
return false
|
||||
val parameterCount = callableDescriptor.valueParameters.size
|
||||
val isExtension = callableDescriptor.extensionReceiverParameter != null
|
||||
val parameterCount = callableDescriptor.valueParameters.size + (if (isExtension) 1 else 0)
|
||||
val funDeclaration = callableDescriptor.containingDeclaration
|
||||
|
||||
val reflectionTypes = callInfo.context.reflectionTypes
|
||||
return if (callableDescriptor.extensionReceiverParameter == null)
|
||||
funDeclaration == callableDescriptor.builtIns.getFunction(parameterCount) ||
|
||||
funDeclaration == reflectionTypes.getKFunction(parameterCount)
|
||||
else
|
||||
funDeclaration == callableDescriptor.builtIns.getExtensionFunction(parameterCount)
|
||||
if (!isExtension && funDeclaration == callInfo.context.reflectionTypes.getKFunction(parameterCount))
|
||||
return true
|
||||
|
||||
return funDeclaration == callableDescriptor.builtIns.getFunction(parameterCount)
|
||||
}
|
||||
|
||||
override fun FunctionCallInfo.dispatchReceiver(): JsExpression {
|
||||
@@ -181,8 +180,8 @@ object InvokeIntrinsic : FunctionCallCase() {
|
||||
}
|
||||
|
||||
/**
|
||||
* A call of extension lambda in compiler looks like as call of invoke function of some ExtensionFunctionN instance.
|
||||
* So that call have both receivers -- some ExtensionFunctionN instance as this and receiverObject as receiver.
|
||||
* A call of extension lambda in compiler looks like as call of invoke function of some FunctionN instance.
|
||||
* So that call have both receivers -- some FunctionN instance as this and receiverObject as receiver.
|
||||
*
|
||||
* in Kotlin code:
|
||||
* obj.extLambda(some, args)
|
||||
|
||||
Reference in New Issue
Block a user