added ability to resolve call with uncustomary tracing strategy

(necessary for special 'tracing for if')
This commit is contained in:
Svetlana Isakova
2013-07-25 17:44:39 +04:00
parent 7842327d20
commit 5d2ae9aec5
4 changed files with 28 additions and 8 deletions
@@ -206,7 +206,7 @@ public class CallResolver {
} }
Collection<ResolutionCandidate<CallableDescriptor>> candidates = TaskPrioritizer.<CallableDescriptor>convertWithImpliedThis(context.scope, Collections.<ReceiverValue>singletonList(NO_RECEIVER), constructors); Collection<ResolutionCandidate<CallableDescriptor>> candidates = TaskPrioritizer.<CallableDescriptor>convertWithImpliedThis(context.scope, Collections.<ReceiverValue>singletonList(NO_RECEIVER), constructors);
prioritizedTasks = TaskPrioritizer.<CallableDescriptor, FunctionDescriptor>computePrioritizedTasksFromCandidates( prioritizedTasks = TaskPrioritizer.<CallableDescriptor, FunctionDescriptor>computePrioritizedTasksFromCandidates(
context, functionReference, candidates); context, functionReference, candidates, null);
} }
else { else {
context.trace.report(NOT_A_CLASS.on(calleeExpression)); context.trace.report(NOT_A_CLASS.on(calleeExpression));
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.calls.tasks;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.psi.Call; import org.jetbrains.jet.lang.psi.Call;
import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression;
@@ -53,12 +54,26 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends C
this.tracing = tracing; this.tracing = tracing;
} }
public ResolutionTask(@NotNull Collection<ResolutionCandidate<D>> candidates, @NotNull JetReferenceExpression reference, @NotNull BasicCallResolutionContext context) { public ResolutionTask(
this(candidates, reference, TracingStrategyImpl.create(reference, context.call), context.trace, context.scope, context.call, @NotNull Collection<ResolutionCandidate<D>> candidates,
@NotNull JetReferenceExpression reference,
@NotNull BasicCallResolutionContext context,
@Nullable TracingStrategy tracing
) {
this(candidates, reference, tracing != null ? tracing : TracingStrategyImpl.create(reference, context.call),
context.trace, context.scope, context.call,
context.expectedType, context.dataFlowInfo, context.resolveMode, context.checkArguments, context.expectedType, context.dataFlowInfo, context.resolveMode, context.checkArguments,
context.expressionPosition, context.resolutionResultsCache); context.expressionPosition, context.resolutionResultsCache);
} }
public ResolutionTask(
@NotNull Collection<ResolutionCandidate<D>> candidates,
@NotNull JetReferenceExpression reference,
@NotNull BasicCallResolutionContext context
) {
this(candidates, reference, context, null);
}
@NotNull @NotNull
public Collection<ResolutionCandidate<D>> getCandidates() { public Collection<ResolutionCandidate<D>> getCandidates() {
return candidates; return candidates;
@@ -34,6 +34,7 @@ public class ResolutionTaskHolder<D extends CallableDescriptor, F extends D> {
private final JetReferenceExpression reference; private final JetReferenceExpression reference;
private final BasicCallResolutionContext basicCallResolutionContext; private final BasicCallResolutionContext basicCallResolutionContext;
private final PriorityProvider<ResolutionCandidate<D>> priorityProvider; private final PriorityProvider<ResolutionCandidate<D>> priorityProvider;
private final TracingStrategy tracing;
private final boolean isSafeCall; private final boolean isSafeCall;
private final Collection<Collection<ResolutionCandidate<D>>> candidatesList = Lists.newArrayList(); private final Collection<Collection<ResolutionCandidate<D>>> candidatesList = Lists.newArrayList();
@@ -42,11 +43,13 @@ public class ResolutionTaskHolder<D extends CallableDescriptor, F extends D> {
public ResolutionTaskHolder(@NotNull JetReferenceExpression reference, public ResolutionTaskHolder(@NotNull JetReferenceExpression reference,
@NotNull BasicCallResolutionContext basicCallResolutionContext, @NotNull BasicCallResolutionContext basicCallResolutionContext,
@NotNull PriorityProvider<ResolutionCandidate<D>> priorityProvider @NotNull PriorityProvider<ResolutionCandidate<D>> priorityProvider,
@Nullable TracingStrategy tracing
) { ) {
this.reference = reference; this.reference = reference;
this.basicCallResolutionContext = basicCallResolutionContext; this.basicCallResolutionContext = basicCallResolutionContext;
this.priorityProvider = priorityProvider; this.priorityProvider = priorityProvider;
this.tracing = tracing;
this.isSafeCall = JetPsiUtil.isSafeCall(basicCallResolutionContext.call); this.isSafeCall = JetPsiUtil.isSafeCall(basicCallResolutionContext.call);
} }
@@ -83,7 +86,7 @@ public class ResolutionTaskHolder<D extends CallableDescriptor, F extends D> {
} }
}); });
if (!filteredCandidates.isEmpty()) { if (!filteredCandidates.isEmpty()) {
tasks.add(new ResolutionTask<D, F>(filteredCandidates, reference, basicCallResolutionContext)); tasks.add(new ResolutionTask<D, F>(filteredCandidates, reference, basicCallResolutionContext, tracing));
} }
} }
} }
@@ -92,7 +92,7 @@ public class TaskPrioritizer {
scope = context.scope; scope = context.scope;
} }
ResolutionTaskHolder<D, F> result = new ResolutionTaskHolder<D, F>(functionReference, context, new MyPriorityProvider<D>(context)); ResolutionTaskHolder<D, F> result = new ResolutionTaskHolder<D, F>(functionReference, context, new MyPriorityProvider<D>(context), null);
TaskPrioritizerContext<D, F> c = new TaskPrioritizerContext<D, F>(name, result, context, scope, callableDescriptorCollectors); TaskPrioritizerContext<D, F> c = new TaskPrioritizerContext<D, F>(name, result, context, scope, callableDescriptorCollectors);
doComputeTasks(explicitReceiver, c); doComputeTasks(explicitReceiver, c);
return result.getTasks(); return result.getTasks();
@@ -337,9 +337,11 @@ public class TaskPrioritizer {
public static <D extends CallableDescriptor, F extends D> List<ResolutionTask<D, F>> computePrioritizedTasksFromCandidates( public static <D extends CallableDescriptor, F extends D> List<ResolutionTask<D, F>> computePrioritizedTasksFromCandidates(
@NotNull BasicCallResolutionContext context, @NotNull BasicCallResolutionContext context,
@NotNull JetReferenceExpression functionReference, @NotNull JetReferenceExpression functionReference,
@NotNull Collection<ResolutionCandidate<D>> candidates @NotNull Collection<ResolutionCandidate<D>> candidates,
@Nullable TracingStrategy tracing
) { ) {
ResolutionTaskHolder<D, F> result = new ResolutionTaskHolder<D, F>(functionReference, context, new MyPriorityProvider<D>(context)); ResolutionTaskHolder<D, F> result = new ResolutionTaskHolder<D, F>(
functionReference, context, new MyPriorityProvider<D>(context), tracing);
result.addCandidates(candidates); result.addCandidates(candidates);
return result.getTasks(); return result.getTasks();
} }