From 53ee30992b2ea6cab03c1a3ebef662067ec77a2c Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 4 Jul 2014 10:03:14 +0400 Subject: [PATCH] Record resolved call on call (not on element) --- .../org/jetbrains/jet/lang/resolve/BindingContext.java | 4 ++-- .../org/jetbrains/jet/lang/resolve/BindingContextUtils.kt | 8 +------- .../resolve/calls/tasks/TracingStrategyForInvoke.java | 2 +- .../jet/lang/resolve/calls/tasks/TracingStrategyImpl.java | 2 +- .../types/expressions/BasicExpressionTypingVisitor.java | 2 +- .../types/expressions/ControlStructureTypingUtils.java | 2 +- .../jet/checkers/AbstractJetDiagnosticsTest.java | 7 ++++--- 7 files changed, 11 insertions(+), 16 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java index 4d4a498c7e1..3d8d378f5f5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java @@ -87,8 +87,8 @@ public interface BindingContext { WritableSlice REFERENCE_TARGET = new BasicWritableSlice(DO_NOTHING); - @KotlinSignature("val RESOLVED_CALL: WritableSlice>") - WritableSlice> RESOLVED_CALL = new BasicWritableSlice>(DO_NOTHING); + @KotlinSignature("val RESOLVED_CALL: WritableSlice>") + WritableSlice> RESOLVED_CALL = new BasicWritableSlice>(DO_NOTHING); WritableSlice, TailRecursionKind> TAIL_RECURSION_CALL = Slices.createSimpleSlice(); WritableSlice CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice(DO_NOTHING); WritableSlice CALL = new BasicWritableSlice(DO_NOTHING); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.kt b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.kt index c22c7ce8a8d..bc60ff6f478 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.kt @@ -80,13 +80,7 @@ public fun JetExpression.getParentCall(context: BindingContext): Call? { } public fun Call?.getResolvedCall(context: BindingContext): ResolvedCall? { - if (this == null) return null - if (this is CallForImplicitInvoke) { - // callee for invoke is implicit (doesn't exist), so the key is callee of outer call (which is 'this object' for 'invoke' call) - return context[RESOLVED_CALL, this.getThisObject().getExpression()] - } - - return context[RESOLVED_CALL, this.getCalleeExpression()] + return context[RESOLVED_CALL, this] } public fun JetElement?.getResolvedCall(context: BindingContext): 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 a37f8654715..d20a8d5fb70 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 @@ -69,7 +69,7 @@ public class TracingStrategyForInvoke extends AbstractTracingStrategy { @NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall ) { if (reference instanceof JetSimpleNameExpression) return; - trace.record(RESOLVED_CALL, reference, resolvedCall); + trace.record(RESOLVED_CALL, call, resolvedCall); } @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 76d10d42665..a1dd0cd20fc 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 @@ -66,7 +66,7 @@ public class TracingStrategyImpl extends AbstractTracingStrategy { @Override public void bindResolvedCall(@NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall) { - trace.record(RESOLVED_CALL, call.getCalleeExpression(), resolvedCall); + trace.record(RESOLVED_CALL, call, resolvedCall); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 4a34eec37c6..662e40ee164 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -425,7 +425,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { new DataFlowInfoForArgumentsImpl(call)); resolvedCall.markCallAsCompleted(); - trace.record(RESOLVED_CALL, expression, resolvedCall); + trace.record(RESOLVED_CALL, call, resolvedCall); trace.record(CALL, expression, call); context.callResolverExtension.run(resolvedCall, 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 b3ed5ba3b98..a41675a282f 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 @@ -332,7 +332,7 @@ public class ControlStructureTypingUtils { public void bindResolvedCall( @NotNull BindingTrace trace, @NotNull ResolvedCall resolvedCall ) { - trace.record(RESOLVED_CALL, call.getCalleeExpression(), resolvedCall); + trace.record(RESOLVED_CALL, call, resolvedCall); } @Override diff --git a/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTest.java b/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTest.java index ef83da0da5d..aed56d0d84d 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTest.java +++ b/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTest.java @@ -29,6 +29,7 @@ import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport; import org.jetbrains.jet.lang.descriptors.DependencyKind; import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl; import org.jetbrains.jet.lang.diagnostics.*; +import org.jetbrains.jet.lang.psi.Call; import org.jetbrains.jet.lang.psi.JetElement; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetFile; @@ -133,9 +134,9 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest { } } - ImmutableMap> resolvedCallsEntries = bindingContext.getSliceContents(BindingContext.RESOLVED_CALL); - for (Map.Entry> entry : resolvedCallsEntries.entrySet()) { - JetElement element = entry.getKey(); + ImmutableMap> resolvedCallsEntries = bindingContext.getSliceContents(BindingContext.RESOLVED_CALL); + for (Map.Entry> entry : resolvedCallsEntries.entrySet()) { + JetElement element = entry.getKey().getCallElement(); ResolvedCall resolvedCall = entry.getValue(); DiagnosticUtils.LineAndColumn lineAndColumn =