Record CALL for all invocations, not only for resolved ones
This commit is contained in:
@@ -285,7 +285,8 @@ public class CallResolver {
|
||||
|
||||
Call call = new CallTransformer.CallForImplicitInvoke(
|
||||
context.call.getExplicitReceiver(), expressionReceiver, context.call);
|
||||
TracingStrategyForInvoke tracingForInvoke = new TracingStrategyForInvoke(calleeExpression, call, calleeType);
|
||||
TracingStrategyForInvoke tracingForInvoke = new TracingStrategyForInvoke(
|
||||
calleeExpression, call, calleeType);
|
||||
return resolveCallForInvoke(context.replaceCall(call), tracingForInvoke);
|
||||
}
|
||||
else {
|
||||
@@ -325,6 +326,8 @@ public class CallResolver {
|
||||
@NotNull CallTransformer<D, F> callTransformer,
|
||||
@NotNull TracingStrategy tracing
|
||||
) {
|
||||
tracing.bindCall(context.trace, context.call);
|
||||
|
||||
OverloadResolutionResultsImpl<F> results = null;
|
||||
TemporaryBindingTrace traceToResolveCall = TemporaryBindingTrace.create(context.trace, "trace to resolve call", context.call);
|
||||
CallKey callKey = CallResolverUtil.createCallKey(context);
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorWithVisibility;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData;
|
||||
@@ -34,6 +35,9 @@ import java.util.List;
|
||||
public interface TracingStrategy {
|
||||
TracingStrategy EMPTY = new TracingStrategy() {
|
||||
|
||||
@Override
|
||||
public void bindCall(@NotNull BindingTrace trace, @NotNull Call call) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall) {}
|
||||
|
||||
@@ -95,6 +99,8 @@ public interface TracingStrategy {
|
||||
public void typeInferenceFailed(@NotNull BindingTrace trace, @NotNull InferenceErrorData inferenceErrorData) {}
|
||||
};
|
||||
|
||||
void bindCall(@NotNull BindingTrace trace, @NotNull Call call);
|
||||
|
||||
<D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall);
|
||||
|
||||
<D extends CallableDescriptor> void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall);
|
||||
|
||||
+9
-1
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.Call;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -42,6 +43,14 @@ public class TracingStrategyForInvoke extends AbstractTracingStrategy {
|
||||
this.calleeType = calleeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindCall(@NotNull BindingTrace trace, @NotNull Call call) {
|
||||
// If reference is a simple name, it's 'variable as function call' case ('foo(a, b)' where 'foo' is a variable).
|
||||
// The outer call is bound ('foo(a, b)'), while 'invoke' call for this case is 'foo.invoke(a, b)' and shouldn't be bound.
|
||||
if (reference instanceof JetSimpleNameExpression) return;
|
||||
trace.record(CALL, reference, call);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindReference(
|
||||
@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall
|
||||
@@ -53,7 +62,6 @@ public class TracingStrategyForInvoke extends AbstractTracingStrategy {
|
||||
@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall
|
||||
) {
|
||||
trace.record(RESOLVED_CALL, reference, resolvedCall);
|
||||
trace.record(CALL, reference, call);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-2
@@ -30,7 +30,9 @@ import java.util.Collection;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.UNRESOLVED_REFERENCE;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.CALL;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.RESOLVED_CALL;
|
||||
|
||||
public class TracingStrategyImpl extends AbstractTracingStrategy {
|
||||
private final JetReferenceExpression reference;
|
||||
@@ -45,6 +47,11 @@ public class TracingStrategyImpl extends AbstractTracingStrategy {
|
||||
return new TracingStrategyImpl(reference, call);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindCall(@NotNull BindingTrace trace, @NotNull Call call) {
|
||||
trace.record(CALL, call.getCalleeExpression(), call);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall) {
|
||||
CallableDescriptor descriptor = resolvedCall.getCandidateDescriptor();
|
||||
@@ -60,7 +67,6 @@ public class TracingStrategyImpl extends AbstractTracingStrategy {
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall) {
|
||||
trace.record(RESOLVED_CALL, call.getCalleeExpression(), resolvedCall);
|
||||
trace.record(CALL, call.getCalleeExpression(), call);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-2
@@ -322,13 +322,16 @@ public class ControlStructureTypingUtils {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindCall(@NotNull BindingTrace trace, @NotNull Call call) {
|
||||
trace.record(CALL, call.getCalleeExpression(), call);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindResolvedCall(
|
||||
@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall
|
||||
) {
|
||||
trace.record(RESOLVED_CALL, call.getCalleeExpression(), resolvedCall);
|
||||
trace.record(CALL, call.getCalleeExpression(), call);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user