Refactoring: extracted isInvokeCallOnVariable
This commit is contained in:
@@ -399,7 +399,7 @@ public class CallResolver {
|
||||
@NotNull OverloadResolutionResultsImpl<D> results,
|
||||
@NotNull TracingStrategy tracing
|
||||
) {
|
||||
if (context.call.getCallType() == Call.CallType.INVOKE) return;
|
||||
if (CallResolverUtil.isInvokeCallOnVariable(context.call)) return;
|
||||
if (!results.isSingleResult()) {
|
||||
if (results.getResultCode() == INCOMPLETE_TYPE_INFERENCE) {
|
||||
argumentTypeResolver.checkTypesWithNoCallee(context, RESOLVE_FUNCTION_ARGUMENTS);
|
||||
@@ -417,7 +417,7 @@ public class CallResolver {
|
||||
@NotNull OverloadResolutionResultsImpl<D> results,
|
||||
@NotNull TracingStrategy tracing
|
||||
) {
|
||||
if (context.call.getCallType() == Call.CallType.INVOKE) return results;
|
||||
if (CallResolverUtil.isInvokeCallOnVariable(context.call)) return results;
|
||||
|
||||
if (results.isSingleResult()) {
|
||||
Set<ValueArgument> unmappedArguments = results.getResultingCall().getCallToCompleteTypeArgumentInference().getUnmappedArguments();
|
||||
|
||||
@@ -21,12 +21,12 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.CallKey;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class CallResolverUtil {
|
||||
|
||||
@Nullable
|
||||
public static CallKey createCallKey(@NotNull BasicCallResolutionContext context) {
|
||||
if (context.call.getCallType() == Call.CallType.INVOKE) {
|
||||
if (isInvokeCallOnVariable(context.call)) {
|
||||
return null;
|
||||
}
|
||||
PsiElement callElement = context.call.getCallElement();
|
||||
@@ -146,4 +146,12 @@ public class CallResolverUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isInvokeCallOnVariable(@NotNull Call call) {
|
||||
if (call.getCallType() != Call.CallType.INVOKE) return false;
|
||||
ReceiverValue thisObject = call.getThisObject();
|
||||
//calleeExpressionAsThisObject for invoke is always ExpressionReceiver, see CallForImplicitInvoke
|
||||
JetExpression expression = ((ExpressionReceiver) thisObject).getExpression();
|
||||
return expression instanceof JetSimpleNameExpression;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ public class CandidateResolver {
|
||||
public <D extends CallableDescriptor> void completeNestedCallsInference(
|
||||
@NotNull CallCandidateResolutionContext<D> context
|
||||
) {
|
||||
if (context.call.getCallType() == Call.CallType.INVOKE) return;
|
||||
if (CallResolverUtil.isInvokeCallOnVariable(context.call)) return;
|
||||
ResolvedCallImpl<D> resolvedCall = context.candidateCall;
|
||||
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : resolvedCall.getValueArguments().entrySet()) {
|
||||
ValueParameterDescriptor parameterDescriptor = entry.getKey();
|
||||
@@ -398,7 +398,7 @@ public class CandidateResolver {
|
||||
}
|
||||
|
||||
private void completeNestedCallsForNotResolvedInvocation(@NotNull CallResolutionContext<?> context, @NotNull Collection<? extends ValueArgument> arguments) {
|
||||
if (context.call.getCallType() == Call.CallType.INVOKE) return;
|
||||
if (CallResolverUtil.isInvokeCallOnVariable(context.call)) return;
|
||||
if (context.checkArguments == CheckValueArgumentsMode.DISABLED) return;
|
||||
|
||||
for (ValueArgument argument : arguments) {
|
||||
|
||||
Reference in New Issue
Block a user