diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index bc165f2a01c..c28dac0bb01 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -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 callTransformer, @NotNull TracingStrategy tracing ) { + tracing.bindCall(context.trace, context.call); + OverloadResolutionResultsImpl results = null; TemporaryBindingTrace traceToResolveCall = TemporaryBindingTrace.create(context.trace, "trace to resolve call", context.call); CallKey callKey = CallResolverUtil.createCallKey(context); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategy.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategy.java index cfda90a9a80..262350ed1dc 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategy.java @@ -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 void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall 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); + void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall); void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyForInvoke.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyForInvoke.java index e2d14d7c61c..a0e52771b29 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyForInvoke.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyForInvoke.java @@ -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 void bindReference( @NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall @@ -53,7 +62,6 @@ public class TracingStrategyForInvoke extends AbstractTracingStrategy { @NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall ) { trace.record(RESOLVED_CALL, reference, resolvedCall); - trace.record(CALL, reference, call); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyImpl.java index 1d70f86cefb..76d10d42665 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TracingStrategyImpl.java @@ -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 void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall) { CallableDescriptor descriptor = resolvedCall.getCandidateDescriptor(); @@ -60,7 +67,6 @@ public class TracingStrategyImpl extends AbstractTracingStrategy { @Override public void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall) { trace.record(RESOLVED_CALL, call.getCalleeExpression(), resolvedCall); - trace.record(CALL, call.getCalleeExpression(), call); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java index 7281e100b63..7e1cdaaa6ab 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java @@ -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 void bindResolvedCall( @NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall ) { trace.record(RESOLVED_CALL, call.getCalleeExpression(), resolvedCall); - trace.record(CALL, call.getCalleeExpression(), call); - } @Override