BasicResolutionContext renamed to BasicCallResolutionContext

This commit is contained in:
Svetlana Isakova
2013-01-28 17:18:19 +04:00
parent dcd358bf3a
commit 0c07cb70ca
10 changed files with 46 additions and 54 deletions
@@ -23,9 +23,9 @@ import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.JetType;
public class BasicResolutionContext extends CallResolutionContext<BasicResolutionContext> {
public class BasicCallResolutionContext extends CallResolutionContext<BasicCallResolutionContext> {
@NotNull
public static BasicResolutionContext create(
public static BasicCallResolutionContext create(
@NotNull BindingTrace trace,
@NotNull JetScope scope,
@NotNull Call call,
@@ -33,20 +33,17 @@ public class BasicResolutionContext extends CallResolutionContext<BasicResolutio
@NotNull DataFlowInfo dataFlowInfo,
boolean namespacesAllowed
) {
return new BasicResolutionContext(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
return new BasicCallResolutionContext(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
}
private BasicResolutionContext(BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo, boolean namespacesAllowed) {
private BasicCallResolutionContext(
BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo, boolean namespacesAllowed
) {
super(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
}
@NotNull
public BasicResolutionContext replaceTrace(@NotNull BindingTrace trace) {
return create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
}
@Override
protected BasicResolutionContext replace(
protected BasicCallResolutionContext replace(
@NotNull BindingTrace trace,
@NotNull JetScope scope,
@NotNull DataFlowInfo dataFlowInfo,
@@ -57,7 +54,7 @@ public class BasicResolutionContext extends CallResolutionContext<BasicResolutio
}
@Override
protected BasicResolutionContext self() {
protected BasicCallResolutionContext self() {
return this;
}
}
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.psi.Call;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.calls.CallResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionTask;
@@ -63,7 +62,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor,
}
public static <D extends CallableDescriptor> CallCandidateResolutionContext<D, D> create(
@NotNull CallResolutionContext context, @NotNull TracingStrategy tracing,
@NotNull BasicCallResolutionContext context, @NotNull TracingStrategy tracing,
@NotNull ResolvedCallImpl<D> candidateCall) {
return new CallCandidateResolutionContext<D, D>(candidateCall, tracing, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.namespacesAllowed);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ public abstract class CallResolutionContext<Context extends CallResolutionContex
this.call = call;
}
public BasicResolutionContext toBasic() {
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
public BasicCallResolutionContext toBasic() {
return BasicCallResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
}
}
@@ -85,7 +85,7 @@ public class CallResolver {
}
@NotNull
public OverloadResolutionResults<VariableDescriptor> resolveSimpleProperty(@NotNull BasicResolutionContext context) {
public OverloadResolutionResults<VariableDescriptor> resolveSimpleProperty(@NotNull BasicCallResolutionContext context) {
JetExpression calleeExpression = context.call.getCalleeExpression();
assert calleeExpression instanceof JetSimpleNameExpression;
JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) calleeExpression;
@@ -107,7 +107,7 @@ public class CallResolver {
@NotNull
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithGivenName(
@NotNull BasicResolutionContext context,
@NotNull BasicCallResolutionContext context,
@NotNull final JetReferenceExpression functionReference,
@NotNull Name name) {
List<ResolutionTask<CallableDescriptor, FunctionDescriptor>> tasks =
@@ -124,11 +124,11 @@ public class CallResolver {
@NotNull JetType expectedType,
@NotNull DataFlowInfo dataFlowInfo
) {
return resolveFunctionCall(BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, false));
return resolveFunctionCall(BasicCallResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, false));
}
@NotNull
public OverloadResolutionResults<FunctionDescriptor> resolveFunctionCall(@NotNull BasicResolutionContext context) {
public OverloadResolutionResults<FunctionDescriptor> resolveFunctionCall(@NotNull BasicCallResolutionContext context) {
ProgressIndicatorProvider.checkCanceled();
@@ -256,7 +256,7 @@ public class CallResolver {
private <D extends CallableDescriptor, F extends D> OverloadResolutionResults<F> doResolveCallOrGetCachedResults(
@NotNull WritableSlice<CallKey, OverloadResolutionResults<F>> resolutionResultsSlice,
@NotNull final BasicResolutionContext context,
@NotNull final BasicCallResolutionContext context,
@NotNull final List<ResolutionTask<D, F>> prioritizedTasks,
@NotNull CallTransformer<D, F> callTransformer,
@NotNull final JetReferenceExpression reference) {
@@ -274,7 +274,7 @@ public class CallResolver {
}
}
if (results == null) {
results = doResolveCall(context.replaceTrace(traceToResolveCall), prioritizedTasks, callTransformer, reference);
results = doResolveCall(context.replaceBindingTrace(traceToResolveCall), prioritizedTasks, callTransformer, reference);
if (results instanceof OverloadResolutionResultsImpl) {
DelegatingBindingTrace deltasTraceForTypeInference = ((OverloadResolutionResultsImpl) results).getTrace();
if (deltasTraceForTypeInference != null) {
@@ -290,13 +290,13 @@ public class CallResolver {
}
TracingStrategy tracing = prioritizedTasks.iterator().next().tracing;
OverloadResolutionResults<F> completeResults = completeTypeInferenceDependentOnExpectedType(
context.replaceTrace(traceToResolveCall), results, tracing);
context.replaceBindingTrace(traceToResolveCall), results, tracing);
traceToResolveCall.commit();
return completeResults;
}
private <D extends CallableDescriptor> OverloadResolutionResults<D> completeTypeInferenceDependentOnExpectedType(
@NotNull BasicResolutionContext context,
@NotNull BasicCallResolutionContext context,
@NotNull OverloadResolutionResults<D> resultsWithIncompleteTypeInference,
@NotNull TracingStrategy tracing
) {
@@ -343,7 +343,7 @@ public class CallResolver {
}
private <F extends CallableDescriptor> void cacheResults(@NotNull WritableSlice<CallKey, OverloadResolutionResults<F>> resolutionResultsSlice,
@NotNull BasicResolutionContext context, @NotNull OverloadResolutionResults<F> results,
@NotNull BasicCallResolutionContext context, @NotNull OverloadResolutionResults<F> results,
@NotNull DelegatingBindingTrace traceToResolveCall) {
//boolean canBeCached = true;
//for (ResolvedCall<? extends CallableDescriptor> call : results.getResultingCalls()) {
@@ -364,14 +364,14 @@ public class CallResolver {
context.trace.record(TRACE_DELTAS_CACHE, (JetExpression) callElement, deltasTraceToCacheResolve);
}
private <D extends CallableDescriptor> OverloadResolutionResults<D> checkArgumentTypesAndFail(BasicResolutionContext context) {
private <D extends CallableDescriptor> OverloadResolutionResults<D> checkArgumentTypesAndFail(BasicCallResolutionContext context) {
argumentTypeResolver.checkTypesWithNoCallee(context);
return OverloadResolutionResultsImpl.nameNotFound();
}
@NotNull
private <D extends CallableDescriptor, F extends D> OverloadResolutionResults<F> doResolveCall(
@NotNull final BasicResolutionContext context,
@NotNull final BasicCallResolutionContext context,
@NotNull final List<ResolutionTask<D, F>> prioritizedTasks, // high to low priority
@NotNull CallTransformer<D, F> callTransformer,
@NotNull final JetReferenceExpression reference) {
@@ -390,7 +390,8 @@ public class CallResolver {
OverloadResolutionResultsImpl<F> resultsForFirstNonemptyCandidateSet = null;
for (ResolutionTask<D, F> task : prioritizedTasks) {
TemporaryBindingTrace taskTrace = TemporaryBindingTrace.create(context.trace, "trace to resolve a task for", task.reference);
OverloadResolutionResultsImpl<F> results = performResolutionGuardedForExtraFunctionLiteralArguments(task.replaceBindingTrace(taskTrace),
OverloadResolutionResultsImpl<F> results = performResolutionGuardedForExtraFunctionLiteralArguments(task.replaceBindingTrace(
taskTrace),
callTransformer, context.trace);
if (results.isSuccess() || results.isAmbiguity()) {
taskTrace.commit();
@@ -427,7 +428,7 @@ public class CallResolver {
}
private <D extends CallableDescriptor> OverloadResolutionResults<D> resolveFunctionArguments(
@NotNull final BasicResolutionContext context,
@NotNull final BasicCallResolutionContext context,
@NotNull OverloadResolutionResults<D> results
) {
if (results.isSingleResult()) {
@@ -190,11 +190,11 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
Call functionCall = createFunctionCall(context, task, returnType);
final DelegatingBindingTrace variableCallTrace = context.candidateCall.getTrace();
BasicResolutionContext basicResolutionContext = BasicResolutionContext.create(
BasicCallResolutionContext basicCallResolutionContext = BasicCallResolutionContext.create(
variableCallTrace, context.scope, functionCall, context.expectedType, context.dataFlowInfo, context.namespacesAllowed);
// 'invoke' call resolve
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenName(basicResolutionContext, task.reference, Name.identifier("invoke"));
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenName(basicCallResolutionContext, task.reference, Name.identifier("invoke"));
Collection<ResolvedCallWithTrace<FunctionDescriptor>> calls = ((OverloadResolutionResultsImpl<FunctionDescriptor>)results).getResultingCalls();
return Collections2.transform(calls, new Function<ResolvedCallWithTrace<FunctionDescriptor>, ResolvedCallWithTrace<FunctionDescriptor>>() {
@@ -2,7 +2,7 @@
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use self() file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@@ -88,7 +88,7 @@ public abstract class ResolutionContext<Context extends ResolutionContext> {
}
@NotNull
public BasicResolutionContext toCallResolutionContext(@NotNull Call call) {
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
public BasicCallResolutionContext toCallResolutionContext(@NotNull Call call) {
return BasicCallResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
}
}
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.BasicCallResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.CallResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
@@ -66,7 +66,7 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends C
this.reference = reference;
}
public ResolutionTask(@NotNull Collection<ResolutionCandidate<D>> candidates, @NotNull JetReferenceExpression reference, @NotNull BasicResolutionContext context) {
public ResolutionTask(@NotNull Collection<ResolutionCandidate<D>> candidates, @NotNull JetReferenceExpression reference, @NotNull BasicCallResolutionContext context) {
this(candidates, reference, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.namespacesAllowed);
}
@@ -25,14 +25,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.BasicCallResolutionContext;
import java.util.Collection;
import java.util.List;
public class ResolutionTaskHolder<D extends CallableDescriptor, F extends D> {
private final JetReferenceExpression reference;
private final BasicResolutionContext basicResolutionContext;
private final BasicCallResolutionContext basicCallResolutionContext;
private final Predicate<ResolutionCandidate<D>> visibleStrategy;
private final boolean isSafeCall;
@@ -43,12 +43,12 @@ public class ResolutionTaskHolder<D extends CallableDescriptor, F extends D> {
private List<ResolutionTask<D, F>> tasks = null;
public ResolutionTaskHolder(@NotNull JetReferenceExpression reference,
@NotNull BasicResolutionContext basicResolutionContext,
@NotNull BasicCallResolutionContext basicCallResolutionContext,
@NotNull Predicate<ResolutionCandidate<D>> visibleStrategy) {
this.reference = reference;
this.basicResolutionContext = basicResolutionContext;
this.basicCallResolutionContext = basicCallResolutionContext;
this.visibleStrategy = visibleStrategy;
this.isSafeCall = JetPsiUtil.isSafeCall(basicResolutionContext.call);
this.isSafeCall = JetPsiUtil.isSafeCall(basicCallResolutionContext.call);
}
public Collection<ResolutionCandidate<D>> setIsSafeCall(@NotNull Collection<ResolutionCandidate<D>> candidates) {
@@ -83,7 +83,7 @@ public class ResolutionTaskHolder<D extends CallableDescriptor, F extends D> {
// If the call is of the form super.foo(), it can actually be only a member
// But if there's no appropriate member, we would like to report that super cannot be a receiver for an extension
// Thus, put members first
if (TaskPrioritizer.getReceiverSuper(basicResolutionContext.call.getExplicitReceiver()) != null) {
if (TaskPrioritizer.getReceiverSuper(basicCallResolutionContext.call.getExplicitReceiver()) != null) {
candidateList.addAll(members);
candidateList.addAll(localExtensions);
}
@@ -97,7 +97,7 @@ public class ResolutionTaskHolder<D extends CallableDescriptor, F extends D> {
for (Collection<ResolutionCandidate<D>> candidates : candidateList) {
Collection<ResolutionCandidate<D>> filteredCandidates = Collections2.filter(candidates, visibilityStrategy);
if (!filteredCandidates.isEmpty()) {
tasks.add(new ResolutionTask<D, F>(filteredCandidates, reference, basicResolutionContext));
tasks.add(new ResolutionTask<D, F>(filteredCandidates, reference, basicCallResolutionContext));
}
}
}
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
import org.jetbrains.jet.lang.psi.JetSuperExpression;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.BasicCallResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastServiceImpl;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
@@ -75,7 +75,7 @@ public abstract class TaskPrioritizer {
}
@NotNull
public static <D extends CallableDescriptor, F extends D> List<ResolutionTask<D, F>> computePrioritizedTasks(@NotNull BasicResolutionContext context, @NotNull Name name,
public static <D extends CallableDescriptor, F extends D> List<ResolutionTask<D, F>> computePrioritizedTasks(@NotNull BasicCallResolutionContext context, @NotNull Name name,
@NotNull JetReferenceExpression functionReference, @NotNull List<CallableDescriptorCollector<? extends D>> callableDescriptorCollectors) {
ReceiverValue explicitReceiver = context.call.getExplicitReceiver();
final JetScope scope;
@@ -106,7 +106,7 @@ public abstract class TaskPrioritizer {
private static <D extends CallableDescriptor, F extends D> void doComputeTasks(@NotNull JetScope scope, @NotNull ReceiverValue receiver,
@NotNull Name name, @NotNull ResolutionTaskHolder<D, F> result,
@NotNull BasicResolutionContext context, @NotNull CallableDescriptorCollector<? extends D> callableDescriptorCollector) {
@NotNull BasicCallResolutionContext context, @NotNull CallableDescriptorCollector<? extends D> callableDescriptorCollector) {
ProgressIndicatorProvider.checkCanceled();
@@ -22,11 +22,10 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.psi.Call;
import org.jetbrains.jet.lang.psi.JetQualifiedExpression;
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.BasicCallResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.ResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
@@ -36,10 +35,6 @@ import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.JetTypeInfo;
import org.jetbrains.jet.lang.types.TypeUtils;
import java.util.List;
public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingContext> {
@@ -113,8 +108,8 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
////////// Call resolution utilities
private BasicResolutionContext makeResolutionContext(@NotNull Call call) {
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
private BasicCallResolutionContext makeResolutionContext(@NotNull Call call) {
return BasicCallResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
}
@NotNull