Removed 'getCallToCompleteTypeArgumentInference'

This commit is contained in:
Svetlana Isakova
2014-04-23 17:54:20 +04:00
parent a2ddce65f4
commit 18ccd0d230
8 changed files with 10 additions and 58 deletions
@@ -376,7 +376,7 @@ public class CallResolver {
} }
CallCandidateResolutionContext<D> candidateContext = CallCandidateResolutionContext.createForCallBeingAnalyzed( CallCandidateResolutionContext<D> candidateContext = CallCandidateResolutionContext.createForCallBeingAnalyzed(
results.getResultingCall().getCallToCompleteTypeArgumentInference(), context, tracing); results.getResultingCall(), context, tracing);
candidateResolver.completeTypeInferenceDependentOnFunctionLiteralsForCall(candidateContext); candidateResolver.completeTypeInferenceDependentOnFunctionLiteralsForCall(candidateContext);
} }
@@ -395,20 +395,19 @@ public class CallResolver {
} }
MutableResolvedCall<D> resolvedCall = results.getResultingCall(); MutableResolvedCall<D> resolvedCall = results.getResultingCall();
ResolvedCallImpl<D> callToCompleteInference = resolvedCall.getCallToCompleteTypeArgumentInference();
Set<ValueArgument> unmappedArguments = callToCompleteInference.getUnmappedArguments(); Set<ValueArgument> unmappedArguments = resolvedCall.getUnmappedArguments();
argumentTypeResolver.checkUnmappedArgumentTypes(context, unmappedArguments); argumentTypeResolver.checkUnmappedArgumentTypes(context, unmappedArguments);
candidateResolver.completeUnmappedArguments(context, unmappedArguments); candidateResolver.completeUnmappedArguments(context, unmappedArguments);
CallCandidateResolutionContext<D> callCandidateResolutionContext = CallCandidateResolutionContext<D> callCandidateResolutionContext =
CallCandidateResolutionContext.createForCallBeingAnalyzed(callToCompleteInference, context, tracing); CallCandidateResolutionContext.createForCallBeingAnalyzed(resolvedCall, context, tracing);
candidateResolver.completeTypeInferenceDependentOnExpectedTypeForCall(callCandidateResolutionContext, false); candidateResolver.completeTypeInferenceDependentOnExpectedTypeForCall(callCandidateResolutionContext, false);
resolvedCall.markCallAsCompleted(); resolvedCall.markCallAsCompleted();
candidateResolver.completeTypeInferenceForAllCandidates(context, results); candidateResolver.completeTypeInferenceForAllCandidates(context, results);
if (callToCompleteInference.getStatus().isSuccess()) { if (resolvedCall.getStatus().isSuccess()) {
return OverloadResolutionResultsImpl.success(resolvedCall); return OverloadResolutionResultsImpl.success(resolvedCall);
} }
return results; return results;
@@ -431,10 +430,9 @@ public class CallResolver {
context.resolutionResultsCache.recordResolutionTrace(callKey, deltasTraceToCacheResolve); context.resolutionResultsCache.recordResolutionTrace(callKey, deltasTraceToCacheResolve);
if (results.isSingleResult()) { if (results.isSingleResult()) {
MutableResolvedCall<F> resultingCall = results.getResultingCall(); CallCandidateResolutionContext<F> contextForCallToCompleteTypeArgumentInference =
CallCandidateResolutionContext<F> contextForCallToCompleteTypeArgumentInference = CallCandidateResolutionContext.createForCallBeingAnalyzed( CallCandidateResolutionContext.createForCallBeingAnalyzed(results.getResultingCall(), context, tracing);
results.getResultingCall().getCallToCompleteTypeArgumentInference(), context, tracing); context.resolutionResultsCache.recordDeferredComputationForCall(callKey, contextForCallToCompleteTypeArgumentInference);
context.resolutionResultsCache.recordDeferredComputationForCall(callKey, resultingCall, contextForCallToCompleteTypeArgumentInference);
} }
} }
@@ -297,10 +297,9 @@ public class CandidateResolver {
TemporaryBindingTrace temporaryBindingTrace = TemporaryBindingTrace.create( TemporaryBindingTrace temporaryBindingTrace = TemporaryBindingTrace.create(
context.trace, "Trace to complete a candidate that is not a resulting call"); context.trace, "Trace to complete a candidate that is not a resulting call");
ResolvedCallImpl<D> callToCompleteInference = mutableResolvedCall.getCallToCompleteTypeArgumentInference();
CallCandidateResolutionContext<D> callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed( CallCandidateResolutionContext<D> callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed(
callToCompleteInference, context.replaceBindingTrace(temporaryBindingTrace), TracingStrategy.EMPTY); mutableResolvedCall, context.replaceBindingTrace(temporaryBindingTrace), TracingStrategy.EMPTY);
completeTypeInferenceDependentOnExpectedTypeForCall(callCandidateResolutionContext, false); completeTypeInferenceDependentOnExpectedTypeForCall(callCandidateResolutionContext, false);
mutableResolvedCall.markCallAsCompleted(); mutableResolvedCall.markCallAsCompleted();
@@ -474,11 +473,6 @@ public class CandidateResolver {
if (storedContextForArgument == null) return; if (storedContextForArgument == null) return;
storedContextForArgument.candidateCall.markCallAsCompleted(); storedContextForArgument.candidateCall.markCallAsCompleted();
// clean data for "invoke" calls
MutableResolvedCall<?> resolvedCall = context.resolutionResultsCache.getCallForArgument(keyExpression);
assert resolvedCall != null : "Resolved call for '" + keyExpression + "' is not stored, but CallCandidateResolutionContext is.";
resolvedCall.markCallAsCompleted();
} }
@Nullable @Nullable
@@ -37,16 +37,11 @@ public interface ResolutionResultsCache {
@Nullable @Nullable
DelegatingBindingTrace getResolutionTrace(@NotNull CallKey callKey); DelegatingBindingTrace getResolutionTrace(@NotNull CallKey callKey);
//For VariableAsFunctionCall deferredComputation is taken for its function call, but resolvedCall is the VariableAsFunctionCall itself.
<D extends CallableDescriptor> void recordDeferredComputationForCall( <D extends CallableDescriptor> void recordDeferredComputationForCall(
@NotNull CallKey callKey, @NotNull CallKey callKey,
@NotNull MutableResolvedCall<D> resolvedCall,
@NotNull CallCandidateResolutionContext<D> deferredComputation @NotNull CallCandidateResolutionContext<D> deferredComputation
); );
@Nullable @Nullable
CallCandidateResolutionContext<?> getDeferredComputation(@Nullable JetExpression expression); CallCandidateResolutionContext<?> getDeferredComputation(@Nullable JetExpression expression);
@Nullable
MutableResolvedCall<?> getCallForArgument(@Nullable JetExpression expression);
} }
@@ -24,7 +24,6 @@ import org.jetbrains.jet.lang.psi.CallKey;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace; import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl;
import org.jetbrains.jet.util.slicedmap.BasicWritableSlice; import org.jetbrains.jet.util.slicedmap.BasicWritableSlice;
import org.jetbrains.jet.util.slicedmap.Slices; import org.jetbrains.jet.util.slicedmap.Slices;
@@ -37,7 +36,6 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
public static final WritableSlice<CallKey, OverloadResolutionResultsImpl<CallableDescriptor>> RESOLUTION_RESULTS = Slices.createSimpleSlice(); public static final WritableSlice<CallKey, OverloadResolutionResultsImpl<CallableDescriptor>> RESOLUTION_RESULTS = Slices.createSimpleSlice();
public static final WritableSlice<CallKey, DelegatingBindingTrace> TRACE_DELTAS_CACHE = Slices.createSimpleSlice(); public static final WritableSlice<CallKey, DelegatingBindingTrace> TRACE_DELTAS_CACHE = Slices.createSimpleSlice();
public static final WritableSlice<CallKey, CallCandidateResolutionContext<?>> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice(); public static final WritableSlice<CallKey, CallCandidateResolutionContext<?>> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice();
public static final WritableSlice<CallKey, MutableResolvedCall<?>> RESOLVED_CALL_FOR_ARGUMENT = Slices.createSimpleSlice();
static { static {
BasicWritableSlice.initSliceDebugNames(ResolutionResultsCacheImpl.class); BasicWritableSlice.initSliceDebugNames(ResolutionResultsCacheImpl.class);
@@ -78,11 +76,9 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
@Override @Override
public <D extends CallableDescriptor> void recordDeferredComputationForCall( public <D extends CallableDescriptor> void recordDeferredComputationForCall(
@NotNull CallKey callKey, @NotNull CallKey callKey,
@NotNull MutableResolvedCall<D> resolvedCall,
@NotNull CallCandidateResolutionContext<D> deferredComputation @NotNull CallCandidateResolutionContext<D> deferredComputation
) { ) {
trace.record(DEFERRED_COMPUTATION_FOR_CALL, callKey, deferredComputation); trace.record(DEFERRED_COMPUTATION_FOR_CALL, callKey, deferredComputation);
trace.record(RESOLVED_CALL_FOR_ARGUMENT, callKey, resolvedCall);
} }
@Override @Override
@@ -107,12 +103,6 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
return null; return null;
} }
@Nullable
@Override
public MutableResolvedCall<?> getCallForArgument(@Nullable JetExpression expression) {
return getValueTryingAllCallTypes(expression, RESOLVED_CALL_FOR_ARGUMENT);
}
@NotNull @NotNull
public static ResolutionResultsCache create() { public static ResolutionResultsCache create() {
return new ResolutionResultsCacheImpl(); return new ResolutionResultsCacheImpl();
@@ -22,7 +22,6 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.psi.CallKey; import org.jetbrains.jet.lang.psi.CallKey;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace; import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl;
public class TemporaryResolutionResultsCache implements ResolutionResultsCache { public class TemporaryResolutionResultsCache implements ResolutionResultsCache {
@@ -76,10 +75,9 @@ public class TemporaryResolutionResultsCache implements ResolutionResultsCache {
@Override @Override
public <D extends CallableDescriptor> void recordDeferredComputationForCall( public <D extends CallableDescriptor> void recordDeferredComputationForCall(
@NotNull CallKey callKey, @NotNull CallKey callKey,
@NotNull MutableResolvedCall<D> resolvedCall,
@NotNull CallCandidateResolutionContext<D> deferredComputation @NotNull CallCandidateResolutionContext<D> deferredComputation
) { ) {
innerCache.recordDeferredComputationForCall(callKey, resolvedCall, deferredComputation); innerCache.recordDeferredComputationForCall(callKey, deferredComputation);
} }
@Nullable @Nullable
@@ -92,16 +90,6 @@ public class TemporaryResolutionResultsCache implements ResolutionResultsCache {
return parentCache.getDeferredComputation(expression); return parentCache.getDeferredComputation(expression);
} }
@Nullable
@Override
public MutableResolvedCall<?> getCallForArgument(@Nullable JetExpression expression) {
MutableResolvedCall<?> resolvedCall = innerCache.getCallForArgument(expression);
if (resolvedCall != null) {
return resolvedCall;
}
return parentCache.getCallForArgument(expression);
}
public void commit() { public void commit() {
if (parentCache instanceof ResolutionResultsCacheImpl) { if (parentCache instanceof ResolutionResultsCacheImpl) {
((ResolutionResultsCacheImpl) parentCache).addData(innerCache); ((ResolutionResultsCacheImpl) parentCache).addData(innerCache);
@@ -58,13 +58,6 @@ public interface MutableResolvedCall<D extends CallableDescriptor> extends Resol
@NotNull @NotNull
DelegatingBindingTrace getTrace(); DelegatingBindingTrace getTrace();
/**
* //todo get rid of Impl class in the interface
* If the call has incomplete type parameters, it should be completed after resolution process is finished.
* Returns this for normal call and function call for VariableAsFunctionCall.
*/
@NotNull
ResolvedCallImpl<D> getCallToCompleteTypeArgumentInference();
void markCallAsCompleted(); void markCallAsCompleted();
@@ -324,12 +324,6 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
return dataFlowInfoForArguments; return dataFlowInfoForArguments;
} }
@NotNull
@Override
public ResolvedCallImpl<D> getCallToCompleteTypeArgumentInference() {
return this;
}
@Override @Override
public boolean hasInferredReturnType() { public boolean hasInferredReturnType() {
if (!completed) { if (!completed) {
@@ -52,7 +52,7 @@ public class OverloadResolutionResultsUtil {
) { ) {
if (results.isSingleResult() && contextDependency == ContextDependency.INDEPENDENT) { if (results.isSingleResult() && contextDependency == ContextDependency.INDEPENDENT) {
ResolvedCall<D> resultingCall = results.getResultingCall(); ResolvedCall<D> resultingCall = results.getResultingCall();
if (!((MutableResolvedCall<D>)resultingCall).getCallToCompleteTypeArgumentInference().hasInferredReturnType()) { if (!((MutableResolvedCall<D>)resultingCall).hasInferredReturnType()) {
return null; return null;
} }
} }