Removed ExpressionAsFunctionDescriptor
This commit is contained in:
@@ -50,7 +50,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.ExpressionAsFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||
@@ -2090,24 +2089,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
@NotNull
|
||||
private CallableMethod resolveToCallableMethod(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull CodegenContext context) {
|
||||
if (isCallAsFunctionObject(fd)) {
|
||||
return typeMapper.mapToFunctionInvokeCallableMethod(createInvoke(fd));
|
||||
}
|
||||
else {
|
||||
SimpleFunctionDescriptor originalOfSamAdapter = (SimpleFunctionDescriptor) SamCodegenUtil.getOriginalIfSamAdapter(fd);
|
||||
return typeMapper.mapToCallableMethod(originalOfSamAdapter != null ? originalOfSamAdapter : fd, superCall, context);
|
||||
}
|
||||
SimpleFunctionDescriptor originalOfSamAdapter = (SimpleFunctionDescriptor) SamCodegenUtil.getOriginalIfSamAdapter(fd);
|
||||
return typeMapper.mapToCallableMethod(originalOfSamAdapter != null ? originalOfSamAdapter : fd, superCall, context);
|
||||
}
|
||||
|
||||
private static boolean isCallAsFunctionObject(FunctionDescriptor fd) {
|
||||
if (fd instanceof ExpressionAsFunctionDescriptor) {
|
||||
JetExpression deparenthesize = JetPsiUtil.deparenthesize(((ExpressionAsFunctionDescriptor) fd).getExpression());
|
||||
return !(deparenthesize instanceof JetCallableReferenceExpression || deparenthesize instanceof JetFunctionLiteralExpression);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void invokeMethodWithArguments(
|
||||
@Nullable Call call,
|
||||
@NotNull CallableMethod callableMethod,
|
||||
|
||||
@@ -31,12 +31,12 @@ import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.ExpressionAsFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
@@ -53,7 +53,6 @@ import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.boxType;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.getTraitImplThisParameterType;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
||||
import static org.jetbrains.jet.codegen.FunctionTypesUtil.getFunctionTraitClassName;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.isVarCapturedInClosure;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
||||
@@ -412,14 +411,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
Type thisClass;
|
||||
Type calleeType = null;
|
||||
|
||||
if (isLocalNamedFun(functionDescriptor) || functionDescriptor instanceof ExpressionAsFunctionDescriptor) {
|
||||
if (functionDescriptor instanceof ExpressionAsFunctionDescriptor) {
|
||||
JetExpression expression = JetPsiUtil.deparenthesize(((ExpressionAsFunctionDescriptor) functionDescriptor).getExpression());
|
||||
if (expression instanceof JetFunctionLiteralExpression) {
|
||||
expression = ((JetFunctionLiteralExpression) expression).getFunctionLiteral();
|
||||
}
|
||||
functionDescriptor = bindingContext.get(BindingContext.FUNCTION, expression);
|
||||
}
|
||||
if (isLocalNamedFun(functionDescriptor)) {
|
||||
functionDescriptor = functionDescriptor.getOriginal();
|
||||
|
||||
owner = asmTypeForAnonymousClass(bindingContext, functionDescriptor);
|
||||
@@ -552,9 +544,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
return PropertyCodegen.setterName(property.getName());
|
||||
}
|
||||
}
|
||||
else if (isLocalNamedFun(descriptor) ||
|
||||
descriptor instanceof AnonymousFunctionDescriptor ||
|
||||
descriptor instanceof ExpressionAsFunctionDescriptor) {
|
||||
else if (isLocalNamedFun(descriptor) || descriptor instanceof AnonymousFunctionDescriptor) {
|
||||
return "invoke";
|
||||
}
|
||||
else {
|
||||
@@ -844,21 +834,6 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CallableMethod mapToFunctionInvokeCallableMethod(@NotNull FunctionDescriptor fd) {
|
||||
JvmMethodSignature signature = erasedInvokeSignature(fd);
|
||||
Type owner = getFunctionTraitClassName(fd);
|
||||
Type receiverParameterType;
|
||||
ReceiverParameterDescriptor receiverParameter = fd.getOriginal().getReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
receiverParameterType = mapType(receiverParameter.getType());
|
||||
}
|
||||
else {
|
||||
receiverParameterType = null;
|
||||
}
|
||||
return new CallableMethod(owner, null, null, signature, INVOKEINTERFACE, owner, receiverParameterType, owner);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static JvmMethodSignature erasedInvokeSignature(@NotNull FunctionDescriptor descriptor) {
|
||||
BothSignatureWriter sw = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD);
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.ExpressionAsFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
@@ -199,10 +198,6 @@ public class JetControlFlowProcessor {
|
||||
if (resultingDescriptor instanceof ReceiverParameterDescriptor) {
|
||||
builder.readThis(expression, (ReceiverParameterDescriptor) resultingDescriptor);
|
||||
}
|
||||
else if (resultingDescriptor instanceof ExpressionAsFunctionDescriptor) {
|
||||
// TODO: no information about actual target
|
||||
builder.readThis(expression, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1067,9 +1062,6 @@ public class JetControlFlowProcessor {
|
||||
}
|
||||
|
||||
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
|
||||
if (resultingDescriptor instanceof ExpressionAsFunctionDescriptor) {
|
||||
generateInstructions(((ExpressionAsFunctionDescriptor) resultingDescriptor).getExpression(), NOT_IN_CONDITION);
|
||||
}
|
||||
|
||||
generateReceiver(resolvedCall.getThisObject());
|
||||
generateReceiver(resolvedCall.getReceiverArgument());
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.jet.lang.resolve.calls.results.ResolutionDebugInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionTask;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.TaskPrioritizer;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.ExpressionAsFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -841,7 +840,6 @@ public class CandidateResolver {
|
||||
) {
|
||||
ResolvedCallImpl<D> candidateCall = context.candidateCall;
|
||||
D candidateDescriptor = candidateCall.getCandidateDescriptor();
|
||||
if (candidateDescriptor instanceof ExpressionAsFunctionDescriptor) return SUCCESS;
|
||||
|
||||
ReceiverParameterDescriptor receiverDescriptor = candidateDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor expectedThisObjectDescriptor = candidateDescriptor.getExpectedThisObject();
|
||||
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.Modality;
|
||||
import org.jetbrains.jet.lang.descriptors.Visibility;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
public class ExpressionAsFunctionDescriptor extends FunctionDescriptorImpl {
|
||||
|
||||
private final JetExpression expression;
|
||||
|
||||
public ExpressionAsFunctionDescriptor(DeclarationDescriptor containingDeclaration, Name name, JetExpression expression) {
|
||||
super(containingDeclaration, Annotations.EMPTY, name, Kind.DECLARATION);
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public JetExpression getExpression() {
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import com.google.dart.compiler.backend.js.ast.JsNew
|
||||
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.ExpressionAsFunctionDescriptor
|
||||
import org.jetbrains.k2js.translate.general.Translation
|
||||
import com.google.dart.compiler.backend.js.ast.JsLiteral
|
||||
import com.google.dart.compiler.backend.js.ast.JsName
|
||||
|
||||
Reference in New Issue
Block a user