diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallExpressionResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallExpressionResolver.java index 2b35a885b97..645873b4381 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallExpressionResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallExpressionResolver.java @@ -33,9 +33,7 @@ import org.jetbrains.jet.lang.resolve.calls.context.CheckValueArgumentsMode; import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext; import org.jetbrains.jet.lang.resolve.calls.context.TemporaryTraceAndCache; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults; -import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsUtil; import org.jetbrains.jet.lang.resolve.calls.util.CallMaker; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index b5a73de7b3b..104927d8c02 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -28,9 +28,9 @@ import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.calls.context.*; import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl; import org.jetbrains.jet.lang.resolve.calls.results.ResolutionDebugInfo; @@ -394,7 +394,7 @@ public class CallResolver { return results; } - ResolvedCallWithTrace resolvedCall = results.getResultingCall(); + MutableResolvedCall resolvedCall = results.getResultingCall(); ResolvedCallImpl callToCompleteInference = resolvedCall.getCallToCompleteTypeArgumentInference(); Set unmappedArguments = callToCompleteInference.getUnmappedArguments(); @@ -431,7 +431,7 @@ public class CallResolver { context.resolutionResultsCache.recordResolutionTrace(callKey, deltasTraceToCacheResolve); if (results.isSingleResult()) { - ResolvedCallWithTrace resultingCall = results.getResultingCall(); + MutableResolvedCall resultingCall = results.getResultingCall(); CallCandidateResolutionContext contextForCallToCompleteTypeArgumentInference = CallCandidateResolutionContext.createForCallBeingAnalyzed( results.getResultingCall().getCallToCompleteTypeArgumentInference(), context, tracing); context.resolutionResultsCache.recordDeferredComputationForCall(callKey, resultingCall, contextForCallToCompleteTypeArgumentInference); @@ -597,9 +597,9 @@ public class CallResolver { to have a binding to variable while 'invoke' call resolve */ task.tracing.bindReference(context.candidateCall.getTrace(), context.candidateCall); - Collection> calls = callTransformer.transformCall(context, this, task); + Collection> calls = callTransformer.transformCall(context, this, task); - for (ResolvedCallWithTrace call : calls) { + for (MutableResolvedCall call : calls) { task.tracing.bindReference(call.getTrace(), call); task.tracing.bindResolvedCall(call.getTrace(), call); task.addResolvedCall(call); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java index 85792dcb351..05212a568c6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java @@ -21,7 +21,6 @@ import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; @@ -32,8 +31,8 @@ import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace; import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext; import org.jetbrains.jet.lang.resolve.calls.context.CallCandidateResolutionContext; import org.jetbrains.jet.lang.resolve.calls.context.ContextDependency; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl; @@ -81,11 +80,11 @@ public class CallTransformer { * the resolved call from callCandidateResolutionContext otherwise */ @NotNull - public Collection> transformCall(@NotNull CallCandidateResolutionContext callCandidateResolutionContext, + public Collection> transformCall(@NotNull CallCandidateResolutionContext callCandidateResolutionContext, @NotNull CallResolver callResolver, @NotNull ResolutionTask task ) { - return Collections.singleton((ResolvedCallWithTrace) callCandidateResolutionContext.candidateCall); + return Collections.singleton((MutableResolvedCall) callCandidateResolutionContext.candidateCall); } @@ -177,7 +176,7 @@ public class CallTransformer { @NotNull @Override - public Collection> transformCall( + public Collection> transformCall( @NotNull CallCandidateResolutionContext context, @NotNull CallResolver callResolver, @NotNull ResolutionTask task @@ -193,7 +192,7 @@ public class CallTransformer { return Collections.emptyList(); } - final ResolvedCallWithTrace variableResolvedCall = (ResolvedCallWithTrace)context.candidateCall; + final MutableResolvedCall variableResolvedCall = (MutableResolvedCall)context.candidateCall; JetExpression calleeExpression = task.call.getCalleeExpression(); if (calleeExpression == null) return Collections.emptyList(); @@ -211,11 +210,11 @@ public class CallTransformer { calleeExpression, functionCall, variableReceiver.getType()); OverloadResolutionResults results = callResolver.resolveCallForInvoke( basicCallResolutionContext, tracingForInvoke); - Collection> calls = ((OverloadResolutionResultsImpl)results).getResultingCalls(); + Collection> calls = ((OverloadResolutionResultsImpl)results).getResultingCalls(); - return Collections2.transform(calls, new Function, ResolvedCallWithTrace>() { + return Collections2.transform(calls, new Function, MutableResolvedCall>() { @Override - public ResolvedCallWithTrace apply(ResolvedCallWithTrace functionResolvedCall) { + public MutableResolvedCall apply(MutableResolvedCall functionResolvedCall) { return new VariableAsFunctionResolvedCall(functionResolvedCall, variableResolvedCall); } }); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java index 0d4a5224579..9925b53c364 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java @@ -293,18 +293,18 @@ public class CandidateResolver { candidates = results.getResultingCalls(); } for (ResolvedCall resolvedCall : candidates) { - ResolvedCallWithTrace resolvedCallWithTrace = (ResolvedCallWithTrace) resolvedCall; - if (resolvedCallWithTrace.isCompleted()) continue; + MutableResolvedCall mutableResolvedCall = (MutableResolvedCall) resolvedCall; + if (mutableResolvedCall.isCompleted()) continue; TemporaryBindingTrace temporaryBindingTrace = TemporaryBindingTrace.create( context.trace, "Trace to complete a candidate that is not a resulting call"); - ResolvedCallImpl callToCompleteInference = resolvedCallWithTrace.getCallToCompleteTypeArgumentInference(); + ResolvedCallImpl callToCompleteInference = mutableResolvedCall.getCallToCompleteTypeArgumentInference(); CallCandidateResolutionContext callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed( callToCompleteInference, context.replaceBindingTrace(temporaryBindingTrace), TracingStrategy.EMPTY); completeTypeInferenceDependentOnExpectedTypeForCall(callCandidateResolutionContext, false); - resolvedCallWithTrace.markCallAsCompleted(); + mutableResolvedCall.markCallAsCompleted(); } } @@ -477,7 +477,7 @@ public class CandidateResolver { storedContextForArgument.candidateCall.markCallAsCompleted(); // clean data for "invoke" calls - ResolvedCallWithTrace resolvedCall = context.resolutionResultsCache.getCallForArgument(keyExpression); + MutableResolvedCall resolvedCall = context.resolutionResultsCache.getCallForArgument(keyExpression); assert resolvedCall != null : "Resolved call for '" + keyExpression + "' is not stored, but CallCandidateResolutionContext is."; resolvedCall.markCallAsCompleted(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionResultsCache.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionResultsCache.java index 688e5e39a2c..ad28769e412 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionResultsCache.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionResultsCache.java @@ -22,7 +22,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.psi.CallKey; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl; public interface ResolutionResultsCache { @@ -40,7 +40,7 @@ public interface ResolutionResultsCache { //For VariableAsFunctionCall deferredComputation is taken for its function call, but resolvedCall is the VariableAsFunctionCall itself. void recordDeferredComputationForCall( @NotNull CallKey callKey, - @NotNull ResolvedCallWithTrace resolvedCall, + @NotNull MutableResolvedCall resolvedCall, @NotNull CallCandidateResolutionContext deferredComputation ); @@ -48,5 +48,5 @@ public interface ResolutionResultsCache { CallCandidateResolutionContext getDeferredComputation(@Nullable JetExpression expression); @Nullable - ResolvedCallWithTrace getCallForArgument(@Nullable JetExpression expression); + MutableResolvedCall getCallForArgument(@Nullable JetExpression expression); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionResultsCacheImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionResultsCacheImpl.java index 33c213bd89a..be1054276a7 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionResultsCacheImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/ResolutionResultsCacheImpl.java @@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.psi.CallKey; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl; import org.jetbrains.jet.util.slicedmap.BasicWritableSlice; import org.jetbrains.jet.util.slicedmap.Slices; @@ -37,7 +37,7 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache { public static final WritableSlice> RESOLUTION_RESULTS = Slices.createSimpleSlice(); public static final WritableSlice TRACE_DELTAS_CACHE = Slices.createSimpleSlice(); public static final WritableSlice> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice(); - public static final WritableSlice> RESOLVED_CALL_FOR_ARGUMENT = Slices.createSimpleSlice(); + public static final WritableSlice> RESOLVED_CALL_FOR_ARGUMENT = Slices.createSimpleSlice(); static { BasicWritableSlice.initSliceDebugNames(ResolutionResultsCacheImpl.class); @@ -78,7 +78,7 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache { @Override public void recordDeferredComputationForCall( @NotNull CallKey callKey, - @NotNull ResolvedCallWithTrace resolvedCall, + @NotNull MutableResolvedCall resolvedCall, @NotNull CallCandidateResolutionContext deferredComputation ) { trace.record(DEFERRED_COMPUTATION_FOR_CALL, callKey, deferredComputation); @@ -109,7 +109,7 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache { @Nullable @Override - public ResolvedCallWithTrace getCallForArgument(@Nullable JetExpression expression) { + public MutableResolvedCall getCallForArgument(@Nullable JetExpression expression) { return getValueTryingAllCallTypes(expression, RESOLVED_CALL_FOR_ARGUMENT); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/TemporaryResolutionResultsCache.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/TemporaryResolutionResultsCache.java index c4593f9a653..dddb32362c8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/TemporaryResolutionResultsCache.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/TemporaryResolutionResultsCache.java @@ -22,7 +22,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.psi.CallKey; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl; public class TemporaryResolutionResultsCache implements ResolutionResultsCache { @@ -76,7 +76,7 @@ public class TemporaryResolutionResultsCache implements ResolutionResultsCache { @Override public void recordDeferredComputationForCall( @NotNull CallKey callKey, - @NotNull ResolvedCallWithTrace resolvedCall, + @NotNull MutableResolvedCall resolvedCall, @NotNull CallCandidateResolutionContext deferredComputation ) { innerCache.recordDeferredComputationForCall(callKey, resolvedCall, deferredComputation); @@ -94,8 +94,8 @@ public class TemporaryResolutionResultsCache implements ResolutionResultsCache { @Nullable @Override - public ResolvedCallWithTrace getCallForArgument(@Nullable JetExpression expression) { - ResolvedCallWithTrace resolvedCall = innerCache.getCallForArgument(expression); + public MutableResolvedCall getCallForArgument(@Nullable JetExpression expression) { + MutableResolvedCall resolvedCall = innerCache.getCallForArgument(expression); if (resolvedCall != null) { return resolvedCall; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/ResolvedCallWithTrace.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableResolvedCall.java similarity index 95% rename from compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/ResolvedCallWithTrace.java rename to compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableResolvedCall.java index 1690bd970db..967c0ef9233 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/ResolvedCallWithTrace.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/MutableResolvedCall.java @@ -21,7 +21,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace; import org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus; -public interface ResolvedCallWithTrace extends ResolvedCall { +public interface MutableResolvedCall extends ResolvedCall { @NotNull ResolutionStatus getStatus(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/ResolvedCallImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/ResolvedCallImpl.java index 29aa65cc4c1..bae855bdf95 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/ResolvedCallImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/ResolvedCallImpl.java @@ -44,18 +44,18 @@ import java.util.*; import static org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus.INCOMPLETE_TYPE_INFERENCE; import static org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus.UNKNOWN_STATUS; -public class ResolvedCallImpl implements ResolvedCallWithTrace { +public class ResolvedCallImpl implements MutableResolvedCall { - public static final Function, CallableDescriptor> MAP_TO_CANDIDATE = new Function, CallableDescriptor>() { + public static final Function, CallableDescriptor> MAP_TO_CANDIDATE = new Function, CallableDescriptor>() { @Override - public CallableDescriptor fun(ResolvedCallWithTrace resolvedCall) { + public CallableDescriptor fun(MutableResolvedCall resolvedCall) { return resolvedCall.getCandidateDescriptor(); } }; - public static final Function, CallableDescriptor> MAP_TO_RESULT = new Function, CallableDescriptor>() { + public static final Function, CallableDescriptor> MAP_TO_RESULT = new Function, CallableDescriptor>() { @Override - public CallableDescriptor fun(ResolvedCallWithTrace resolvedCall) { + public CallableDescriptor fun(MutableResolvedCall resolvedCall) { return resolvedCall.getResultingDescriptor(); } }; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/VariableAsFunctionResolvedCall.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/VariableAsFunctionResolvedCall.java index a3d5636d5d3..e46b414f2db 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/VariableAsFunctionResolvedCall.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/model/VariableAsFunctionResolvedCall.java @@ -33,23 +33,23 @@ import org.jetbrains.jet.lang.types.JetType; import java.util.List; import java.util.Map; -public class VariableAsFunctionResolvedCall implements ResolvedCallWithTrace { - private final ResolvedCallWithTrace functionCall; - private final ResolvedCallWithTrace variableCall; +public class VariableAsFunctionResolvedCall implements MutableResolvedCall { + private final MutableResolvedCall functionCall; + private final MutableResolvedCall variableCall; - public VariableAsFunctionResolvedCall(@NotNull ResolvedCallWithTrace functionCall, - @NotNull ResolvedCallWithTrace variableCall) { + public VariableAsFunctionResolvedCall(@NotNull MutableResolvedCall functionCall, + @NotNull MutableResolvedCall variableCall) { this.functionCall = functionCall; this.variableCall = variableCall; } @NotNull - public ResolvedCallWithTrace getFunctionCall() { + public MutableResolvedCall getFunctionCall() { return functionCall; } @NotNull - public ResolvedCallWithTrace getVariableCall() { + public MutableResolvedCall getVariableCall() { return variableCall; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadResolutionResultsImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadResolutionResultsImpl.java index 145d8067ef4..48b8f1c3880 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadResolutionResultsImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadResolutionResultsImpl.java @@ -20,67 +20,67 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; import java.util.Collection; import java.util.Collections; public class OverloadResolutionResultsImpl implements OverloadResolutionResults { - public static OverloadResolutionResultsImpl success(@NotNull ResolvedCallWithTrace candidate) { + public static OverloadResolutionResultsImpl success(@NotNull MutableResolvedCall candidate) { return new OverloadResolutionResultsImpl(Code.SUCCESS, Collections.singleton(candidate)); } public static OverloadResolutionResultsImpl nameNotFound() { OverloadResolutionResultsImpl results = new OverloadResolutionResultsImpl( - Code.NAME_NOT_FOUND, Collections.>emptyList()); + Code.NAME_NOT_FOUND, Collections.>emptyList()); results.setAllCandidates(Collections.>emptyList()); return results; } - public static OverloadResolutionResultsImpl singleFailedCandidate(ResolvedCallWithTrace candidate) { + public static OverloadResolutionResultsImpl singleFailedCandidate(MutableResolvedCall candidate) { return new OverloadResolutionResultsImpl(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate)); } - public static OverloadResolutionResultsImpl manyFailedCandidates(Collection> failedCandidates) { + public static OverloadResolutionResultsImpl manyFailedCandidates(Collection> failedCandidates) { return new OverloadResolutionResultsImpl(Code.MANY_FAILED_CANDIDATES, failedCandidates); } - public static OverloadResolutionResultsImpl candidatesWithWrongReceiver(Collection> failedCandidates) { + public static OverloadResolutionResultsImpl candidatesWithWrongReceiver(Collection> failedCandidates) { return new OverloadResolutionResultsImpl(Code.CANDIDATES_WITH_WRONG_RECEIVER, failedCandidates); } - public static OverloadResolutionResultsImpl ambiguity(Collection> candidates) { + public static OverloadResolutionResultsImpl ambiguity(Collection> candidates) { return new OverloadResolutionResultsImpl(Code.AMBIGUITY, candidates); } - public static OverloadResolutionResultsImpl incompleteTypeInference(Collection> candidates) { + public static OverloadResolutionResultsImpl incompleteTypeInference(Collection> candidates) { return new OverloadResolutionResultsImpl(Code.INCOMPLETE_TYPE_INFERENCE, candidates); } - public static OverloadResolutionResultsImpl incompleteTypeInference(ResolvedCallWithTrace candidate) { + public static OverloadResolutionResultsImpl incompleteTypeInference(MutableResolvedCall candidate) { return incompleteTypeInference(Collections.singleton(candidate)); } - private final Collection> results; + private final Collection> results; private final Code resultCode; private DelegatingBindingTrace trace; private Collection> allCandidates; - private OverloadResolutionResultsImpl(@NotNull Code resultCode, @NotNull Collection> results) { + private OverloadResolutionResultsImpl(@NotNull Code resultCode, @NotNull Collection> results) { this.results = results; this.resultCode = resultCode; } @Override @NotNull - public Collection> getResultingCalls() { + public Collection> getResultingCalls() { return results; } @Override @NotNull - public ResolvedCallWithTrace getResultingCall() { + public MutableResolvedCall getResultingCall() { assert isSingleResult(); return results.iterator().next(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadResolutionResultsUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadResolutionResultsUtil.java index 6ea026fce55..27c50756dce 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadResolutionResultsUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadResolutionResultsUtil.java @@ -20,10 +20,9 @@ import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; -import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil; import org.jetbrains.jet.lang.resolve.calls.context.ContextDependency; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; import org.jetbrains.jet.lang.types.JetType; import java.util.Collection; @@ -31,9 +30,9 @@ import java.util.Collection; public class OverloadResolutionResultsUtil { @NotNull public static OverloadResolutionResults ambiguity(OverloadResolutionResults results1, OverloadResolutionResults results2) { - Collection> resultingCalls = Lists.newArrayList(); - resultingCalls.addAll((Collection>) results1.getResultingCalls()); - resultingCalls.addAll((Collection>) results2.getResultingCalls()); + Collection> resultingCalls = Lists.newArrayList(); + resultingCalls.addAll((Collection>) results1.getResultingCalls()); + resultingCalls.addAll((Collection>) results2.getResultingCalls()); return OverloadResolutionResultsImpl.ambiguity(resultingCalls); } @@ -53,7 +52,7 @@ public class OverloadResolutionResultsUtil { ) { if (results.isSingleResult() && contextDependency == ContextDependency.INDEPENDENT) { ResolvedCall resultingCall = results.getResultingCall(); - if (!((ResolvedCallWithTrace)resultingCall).getCallToCompleteTypeArgumentInference().hasInferredReturnType()) { + if (!((MutableResolvedCall)resultingCall).getCallToCompleteTypeArgumentInference().hasInferredReturnType()) { return null; } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java index e153314e2a8..d2f7f1b4253 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.OverrideResolver; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeUtils; @@ -40,23 +40,23 @@ public class OverloadingConflictResolver { private OverloadingConflictResolver() {} @Nullable - public ResolvedCallWithTrace findMaximallySpecific( - @NotNull Set> candidates, + public MutableResolvedCall findMaximallySpecific( + @NotNull Set> candidates, boolean discriminateGenericDescriptors ) { // Different autocasts may lead to the same candidate descriptor wrapped into different ResolvedCallImpl objects - Set> maximallySpecific = new THashSet>(new TObjectHashingStrategy>() { + Set> maximallySpecific = new THashSet>(new TObjectHashingStrategy>() { @Override - public boolean equals(ResolvedCallWithTrace o1, ResolvedCallWithTrace o2) { + public boolean equals(MutableResolvedCall o1, MutableResolvedCall o2) { return o1 == null ? o2 == null : o1.getResultingDescriptor().equals(o2.getResultingDescriptor()); } @Override - public int computeHashCode(ResolvedCallWithTrace object) { + public int computeHashCode(MutableResolvedCall object) { return object == null ? 0 : object.getResultingDescriptor().hashCode(); } }); - for (ResolvedCallWithTrace candidateCall : candidates) { + for (MutableResolvedCall candidateCall : candidates) { if (isMaximallySpecific(candidateCall, candidates, discriminateGenericDescriptors)) { maximallySpecific.add(candidateCall); } @@ -65,8 +65,8 @@ public class OverloadingConflictResolver { } private boolean isMaximallySpecific( - @NotNull ResolvedCallWithTrace candidateCall, - @NotNull Set> candidates, + @NotNull MutableResolvedCall candidateCall, + @NotNull Set> candidates, boolean discriminateGenericDescriptors ) { D me = candidateCall.getResultingDescriptor(); @@ -80,7 +80,7 @@ public class OverloadingConflictResolver { variable = null; } - for (ResolvedCallWithTrace otherCall : candidates) { + for (MutableResolvedCall otherCall : candidates) { D other = otherCall.getResultingDescriptor(); if (other == me) continue; @@ -89,7 +89,7 @@ public class OverloadingConflictResolver { if (!isInvoke) return false; assert otherCall instanceof VariableAsFunctionResolvedCall : "'invoke' candidate goes with usual one: " + candidateCall + otherCall; - ResolvedCallWithTrace otherVariableCall = ((VariableAsFunctionResolvedCall) otherCall).getVariableCall(); + MutableResolvedCall otherVariableCall = ((VariableAsFunctionResolvedCall) otherCall).getVariableCall(); if (definitelyNotMaximallySpecific(variable, otherVariableCall.getResultingDescriptor(), discriminateGenericDescriptors)) { return false; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/ResolutionResultsHandler.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/ResolutionResultsHandler.java index c6daa385ce9..65f6629b4c5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/ResolutionResultsHandler.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/ResolutionResultsHandler.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.OverrideResolver; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy; import java.util.*; @@ -39,13 +39,13 @@ public class ResolutionResultsHandler { public OverloadResolutionResultsImpl computeResultAndReportErrors( @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, - @NotNull Collection> candidates + @NotNull Collection> candidates ) { - Set> successfulCandidates = Sets.newLinkedHashSet(); - Set> failedCandidates = Sets.newLinkedHashSet(); - Set> incompleteCandidates = Sets.newLinkedHashSet(); - Set> candidatesWithWrongReceiver = Sets.newLinkedHashSet(); - for (ResolvedCallWithTrace candidateCall : candidates) { + Set> successfulCandidates = Sets.newLinkedHashSet(); + Set> failedCandidates = Sets.newLinkedHashSet(); + Set> incompleteCandidates = Sets.newLinkedHashSet(); + Set> candidatesWithWrongReceiver = Sets.newLinkedHashSet(); + for (MutableResolvedCall candidateCall : candidates) { ResolutionStatus status = candidateCall.getStatus(); assert status != UNKNOWN_STATUS : "No resolution for " + candidateCall.getCandidateDescriptor(); if (status.isSuccess()) { @@ -81,15 +81,15 @@ public class ResolutionResultsHandler { private OverloadResolutionResultsImpl computeSuccessfulResult( BindingTrace trace, TracingStrategy tracing, - Set> successfulCandidates, - Set> incompleteCandidates + Set> successfulCandidates, + Set> incompleteCandidates ) { - Set> successfulAndIncomplete = Sets.newLinkedHashSet(); + Set> successfulAndIncomplete = Sets.newLinkedHashSet(); successfulAndIncomplete.addAll(successfulCandidates); successfulAndIncomplete.addAll(incompleteCandidates); OverloadResolutionResultsImpl results = chooseAndReportMaximallySpecific(successfulAndIncomplete, true); if (results.isSingleResult()) { - ResolvedCallWithTrace resultingCall = results.getResultingCall(); + MutableResolvedCall resultingCall = results.getResultingCall(); resultingCall.getTrace().moveAllMyDataTo(trace); if (resultingCall.getStatus() == INCOMPLETE_TYPE_INFERENCE) { return OverloadResolutionResultsImpl.incompleteTypeInference(resultingCall); @@ -114,15 +114,15 @@ public class ResolutionResultsHandler { private OverloadResolutionResultsImpl computeFailedResult( BindingTrace trace, TracingStrategy tracing, - Set> failedCandidates + Set> failedCandidates ) { if (failedCandidates.size() != 1) { // This is needed when there are several overloads some of which are OK but for nullability of the receiver, // and some are not OK at all. In this case we'd like to say "unsafe call" rather than "none applicable" // Used to be: weak errors. Generalized for future extensions for (EnumSet severityLevel : SEVERITY_LEVELS) { - Set> thisLevel = Sets.newLinkedHashSet(); - for (ResolvedCallWithTrace candidate : failedCandidates) { + Set> thisLevel = Sets.newLinkedHashSet(); + for (MutableResolvedCall candidate : failedCandidates) { if (severityLevel.contains(candidate.getStatus())) { thisLevel.add(candidate); } @@ -142,7 +142,7 @@ public class ResolutionResultsHandler { assert false : "Should not be reachable, cause every status must belong to some level"; - Set> noOverrides = OverrideResolver.filterOutOverridden(failedCandidates, MAP_TO_CANDIDATE); + Set> noOverrides = OverrideResolver.filterOutOverridden(failedCandidates, MAP_TO_CANDIDATE); if (noOverrides.size() != 1) { tracing.noneApplicable(trace, noOverrides); tracing.recordAmbiguity(trace, noOverrides); @@ -152,20 +152,20 @@ public class ResolutionResultsHandler { failedCandidates = noOverrides; } - ResolvedCallWithTrace failed = failedCandidates.iterator().next(); + MutableResolvedCall failed = failedCandidates.iterator().next(); failed.getTrace().moveAllMyDataTo(trace); return OverloadResolutionResultsImpl.singleFailedCandidate(failed); } - private static boolean allClean(@NotNull Collection> results) { - for (ResolvedCallWithTrace result : results) { + private static boolean allClean(@NotNull Collection> results) { + for (MutableResolvedCall result : results) { if (result.isDirty()) return false; } return true; } - private static boolean allIncomplete(@NotNull Collection> results) { - for (ResolvedCallWithTrace result : results) { + private static boolean allIncomplete(@NotNull Collection> results) { + for (MutableResolvedCall result : results) { if (result.getStatus() != INCOMPLETE_TYPE_INFERENCE) return false; } return true; @@ -173,16 +173,16 @@ public class ResolutionResultsHandler { @NotNull private OverloadResolutionResultsImpl chooseAndReportMaximallySpecific( - @NotNull Set> candidates, + @NotNull Set> candidates, boolean discriminateGenerics ) { if (candidates.size() == 1) { return OverloadResolutionResultsImpl.success(candidates.iterator().next()); } - Set> cleanCandidates = Sets.newLinkedHashSet(candidates); - for (Iterator> iterator = cleanCandidates.iterator(); iterator.hasNext(); ) { - ResolvedCallWithTrace candidate = iterator.next(); + Set> cleanCandidates = Sets.newLinkedHashSet(candidates); + for (Iterator> iterator = cleanCandidates.iterator(); iterator.hasNext(); ) { + MutableResolvedCall candidate = iterator.next(); if (candidate.isDirty()) { iterator.remove(); } @@ -191,19 +191,19 @@ public class ResolutionResultsHandler { if (cleanCandidates.isEmpty()) { cleanCandidates = candidates; } - ResolvedCallWithTrace maximallySpecific = OverloadingConflictResolver.INSTANCE.findMaximallySpecific(cleanCandidates, false); + MutableResolvedCall maximallySpecific = OverloadingConflictResolver.INSTANCE.findMaximallySpecific(cleanCandidates, false); if (maximallySpecific != null) { return OverloadResolutionResultsImpl.success(maximallySpecific); } if (discriminateGenerics) { - ResolvedCallWithTrace maximallySpecificGenericsDiscriminated = OverloadingConflictResolver.INSTANCE.findMaximallySpecific(cleanCandidates, true); + MutableResolvedCall maximallySpecificGenericsDiscriminated = OverloadingConflictResolver.INSTANCE.findMaximallySpecific(cleanCandidates, true); if (maximallySpecificGenericsDiscriminated != null) { return OverloadResolutionResultsImpl.success(maximallySpecificGenericsDiscriminated); } } - Set> noOverrides = OverrideResolver.filterOutOverridden(candidates, MAP_TO_RESULT); + Set> noOverrides = OverrideResolver.filterOutOverridden(candidates, MAP_TO_RESULT); if (noOverrides.size() == 1) { return OverloadResolutionResultsImpl.success(noOverrides.iterator().next()); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java index 9433eed6940..1997a3d143e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java @@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.calls.context.*; import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.expressions.LabelResolver; @@ -39,7 +39,7 @@ import java.util.Collection; */ public class ResolutionTask extends CallResolutionContext> { private final Collection> candidates; - private final Collection> resolvedCalls; + private final Collection> resolvedCalls; private DescriptorCheckStrategy checkingStrategy; public final TracingStrategy tracing; @@ -57,7 +57,7 @@ public class ResolutionTask extends C @NotNull LabelResolver labelResolver, @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments, @NotNull CallResolverExtension callResolverExtension, - @NotNull Collection> resolvedCalls, + @NotNull Collection> resolvedCalls, boolean isAnnotationContext, boolean collectAllCandidates ) { @@ -77,7 +77,7 @@ public class ResolutionTask extends C context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache, context.labelResolver, context.dataFlowInfoForArguments, - context.callResolverExtension, Lists.>newArrayList(), context.isAnnotationContext, context.collectAllCandidates); + context.callResolverExtension, Lists.>newArrayList(), context.isAnnotationContext, context.collectAllCandidates); } public ResolutionTask( @@ -93,12 +93,12 @@ public class ResolutionTask extends C return candidates; } - public void addResolvedCall(@NotNull ResolvedCallWithTrace resolvedCall) { + public void addResolvedCall(@NotNull MutableResolvedCall resolvedCall) { resolvedCalls.add(resolvedCall); } @NotNull - public Collection> getResolvedCalls() { + public Collection> getResolvedCalls() { return resolvedCalls; } diff --git a/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTest.java b/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTest.java index 357eae46063..f1fa37b226f 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTest.java +++ b/compiler/tests/org/jetbrains/jet/checkers/AbstractJetDiagnosticsTest.java @@ -28,8 +28,8 @@ import org.jetbrains.jet.lang.psi.JetElement; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; import java.io.File; @@ -79,7 +79,7 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest { DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange()); assertTrue("Resolved call for '" + element.getText() + "'" + lineAndColumn + " in not completed", - ((ResolvedCallWithTrace) resolvedCall).isCompleted()); + ((MutableResolvedCall) resolvedCall).isCompleted()); } } }