ResolvedCall recorder for the correct element

This commit is contained in:
Andrey Breslav
2011-11-04 14:40:45 +03:00
parent 2f191d3c43
commit da3936ddd9
2 changed files with 40 additions and 5 deletions
@@ -193,8 +193,11 @@ public class CallResolver {
resolvedCall.setReceiverArgument(call.getExplicitReceiver()); resolvedCall.setReceiverArgument(call.getExplicitReceiver());
prioritizedTasks = Collections.singletonList(new ResolutionTask<FunctionDescriptor>( prioritizedTasks = Collections.singletonList(new ResolutionTask<FunctionDescriptor>(
Collections.singleton(resolvedCall), call, dataFlowInfo)); Collections.singleton(resolvedCall), call, dataFlowInfo));
functionReference = new JetReferenceExpression(calleeExpression.getNode()) {
}; // strictly speaking, this is a hack:
// we need to pass a reference, but there's no reference in the PSI,
// so we wrap what we have into a fake reference and pass it on (unwrap on the other end)
functionReference = new JetFakeReference(calleeExpression);
} }
else { else {
checkTypesWithNoCallee(trace, scope, call); checkTypesWithNoCallee(trace, scope, call);
@@ -239,9 +242,17 @@ public class CallResolver {
// trace.record(REFERENCE_TARGET, reference, variableAsFunctionDescriptor.getVariableDescriptor()); // trace.record(REFERENCE_TARGET, reference, variableAsFunctionDescriptor.getVariableDescriptor());
// } // }
// else { // else {
trace.record(REFERENCE_TARGET, reference, descriptor);
// } // }
if (reference instanceof JetFakeReference) {
// This means that the callable being invoked was represented by an expression
// rather than a reference expression
JetFakeReference fakeReference = (JetFakeReference) reference;
trace.record(RESOLVED_CALL, fakeReference.getActualElement(), resolvedCall);
}
else {
trace.record(RESOLVED_CALL, reference, resolvedCall); trace.record(RESOLVED_CALL, reference, resolvedCall);
trace.record(REFERENCE_TARGET, reference, descriptor);
}
} }
@Override @Override
@@ -0,0 +1,24 @@
package org.jetbrains.jet.lang.resolve.calls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetElement;
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
/**
*
* This class is used to wrap an expression that occurs in a reference position, such as a function literal, into a reference expression
*
* @author abreslav
*/
public class JetFakeReference extends JetReferenceExpression {
private final JetElement actualElement;
public JetFakeReference(@NotNull JetElement actualElement) {
super(actualElement.getNode());
this.actualElement = actualElement;
}
public JetElement getActualElement() {
return actualElement;
}
}