Read-only interface extracted from ResolvedCall
This commit is contained in:
@@ -1129,7 +1129,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
|
||||
private int pushMethodArguments(JetCallElement expression, List<Type> valueParameterTypes) {
|
||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
||||
ResolvedCallImpl<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
||||
List<? extends ValueArgument> args = expression.getValueArguments();
|
||||
if(resolvedCall != null) {
|
||||
Map<ValueParameterDescriptor,ResolvedValueArgument> valueArguments = resolvedCall.getValueArguments();
|
||||
@@ -1791,7 +1791,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
|
||||
private void pushTypeArguments(JetCallElement expression) {
|
||||
// todo when frontend calculates
|
||||
// ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
||||
// ResolvedCallImpl<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
||||
// if(resolvedCall != null) {
|
||||
// Map<TypeParameterDescriptor, JetType> typeArguments = resolvedCall.getTypeArguments();
|
||||
// CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
|
||||
|
||||
+4
-4
@@ -2,7 +2,7 @@ package org.jetbrains.jet.lang.diagnostics;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -10,7 +10,7 @@ import java.util.Collection;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class AmbiguousDescriptorDiagnosticFactory extends ParameterizedDiagnosticFactory1<Collection<? extends ResolvedCall<? extends DeclarationDescriptor>>> {
|
||||
public class AmbiguousDescriptorDiagnosticFactory extends ParameterizedDiagnosticFactory1<Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>>> {
|
||||
public static AmbiguousDescriptorDiagnosticFactory create(String messageTemplate) {
|
||||
return new AmbiguousDescriptorDiagnosticFactory(messageTemplate);
|
||||
}
|
||||
@@ -20,9 +20,9 @@ public class AmbiguousDescriptorDiagnosticFactory extends ParameterizedDiagnosti
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String makeMessageFor(@NotNull Collection<? extends ResolvedCall<? extends DeclarationDescriptor>> argument) {
|
||||
protected String makeMessageFor(@NotNull Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>> argument) {
|
||||
StringBuilder stringBuilder = new StringBuilder("\n");
|
||||
for (ResolvedCall<? extends DeclarationDescriptor> call : argument) {
|
||||
for (ResolvedCallImpl<? extends DeclarationDescriptor> call : argument) {
|
||||
stringBuilder.append(DescriptorRenderer.TEXT.render(call.getResultingDescriptor())).append("\n");
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.DeferredType;
|
||||
@@ -27,9 +27,9 @@ public interface BindingContext {
|
||||
WritableSlice<JetExpression, JetType> EXPRESSION_TYPE = new BasicWritableSlice<JetExpression, JetType>("EXPRESSION_TYPE", RewritePolicy.DO_NOTHING);
|
||||
|
||||
WritableSlice<JetReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>("REFERENCE_TARGET", RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>> RESOLVED_CALL = new BasicWritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>>("RESOLVED_CALL", RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetElement, ResolvedCallImpl<? extends CallableDescriptor>> RESOLVED_CALL = new BasicWritableSlice<JetElement, ResolvedCallImpl<? extends CallableDescriptor>>("RESOLVED_CALL", RewritePolicy.DO_NOTHING);
|
||||
|
||||
WritableSlice<JetReferenceExpression, Collection<? extends ResolvedCall<? extends DeclarationDescriptor>>> AMBIGUOUS_REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, Collection<? extends ResolvedCall<? extends DeclarationDescriptor>>>("AMBIGUOUS_REFERENCE_TARGET", RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetReferenceExpression, Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>>> AMBIGUOUS_REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>>>("AMBIGUOUS_REFERENCE_TARGET", RewritePolicy.DO_NOTHING);
|
||||
|
||||
WritableSlice<JetExpression, FunctionDescriptor> LOOP_RANGE_ITERATOR = Slices.createSimpleSlice("LOOP_RANGE_ITERATOR");
|
||||
WritableSlice<JetExpression, CallableDescriptor> LOOP_RANGE_HAS_NEXT = Slices.createSimpleSlice("LOOP_RANGE_HAS_NEXT");
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.util.*;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.ResolutionStatus.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.ResolvedCall.MAP_TO_CANDIDATE;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.ResolvedCall.MAP_TO_RESULT;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl.MAP_TO_CANDIDATE;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl.MAP_TO_RESULT;
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor.NO_RECEIVER;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
|
||||
@@ -171,7 +171,7 @@ public class CallResolver {
|
||||
trace.report(NO_CONSTRUCTOR.on(reportAbsenceOn));
|
||||
return checkArgumentTypesAndFail(trace, scope, call);
|
||||
}
|
||||
prioritizedTasks = Collections.singletonList(new ResolutionTask<FunctionDescriptor>(ResolvedCall.convertCollection(constructors), call, DataFlowInfo.EMPTY));
|
||||
prioritizedTasks = Collections.singletonList(new ResolutionTask<FunctionDescriptor>(ResolvedCallImpl.convertCollection(constructors), call, DataFlowInfo.EMPTY));
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("Type argument inference not implemented for " + call);
|
||||
@@ -194,12 +194,12 @@ public class CallResolver {
|
||||
@NotNull JetType expectedType,
|
||||
@NotNull final List<ResolutionTask<D>> prioritizedTasks, // high to low priority
|
||||
@NotNull final JetReferenceExpression reference) {
|
||||
ResolvedCall<D> resolvedCall = doResolveCall(trace, scope, call, expectedType, prioritizedTasks, reference);
|
||||
ResolvedCallImpl<D> resolvedCall = doResolveCall(trace, scope, call, expectedType, prioritizedTasks, reference);
|
||||
return resolvedCall == null ? null : resolvedCall.getResultingDescriptor();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <D extends CallableDescriptor> ResolvedCall<D> doResolveCall(
|
||||
private <D extends CallableDescriptor> ResolvedCallImpl<D> doResolveCall(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope scope,
|
||||
@NotNull final Call call,
|
||||
@@ -210,7 +210,7 @@ public class CallResolver {
|
||||
OverloadResolutionResults<D> resultsForFirstNonemptyCandidateSet = null;
|
||||
TracingStrategy tracing = new TracingStrategy() {
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall) {
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallImpl<D> resolvedCall) {
|
||||
D descriptor = resolvedCall.getCandidateDescriptor();
|
||||
// if (descriptor instanceof VariableAsFunctionDescriptor) {
|
||||
// VariableAsFunctionDescriptor variableAsFunctionDescriptor = (VariableAsFunctionDescriptor) descriptor;
|
||||
@@ -223,7 +223,7 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCall<D>> candidates) {
|
||||
public <D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallImpl<D>> candidates) {
|
||||
trace.record(AMBIGUOUS_REFERENCE_TARGET, reference, candidates);
|
||||
}
|
||||
|
||||
@@ -272,12 +272,12 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Set<ResolvedCall<D>> descriptors) {
|
||||
public <D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Set<ResolvedCallImpl<D>> descriptors) {
|
||||
trace.report(OVERLOAD_RESOLUTION_AMBIGUITY.on(call.getCallNode(), descriptors));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Set<ResolvedCall<D>> descriptors) {
|
||||
public <D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Set<ResolvedCallImpl<D>> descriptors) {
|
||||
trace.report(NONE_APPLICABLE.on(reference, descriptors));
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ public class CallResolver {
|
||||
|
||||
@NotNull
|
||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> performResolution(@NotNull BindingTrace trace, @NotNull JetScope scope, @NotNull JetType expectedType, @NotNull ResolutionTask<D> task, @NotNull TracingStrategy tracing) {
|
||||
for (ResolvedCall<D> candidateCall : task.getCandidates()) {
|
||||
for (ResolvedCallImpl<D> candidateCall : task.getCandidates()) {
|
||||
D candidate = candidateCall.getCandidateDescriptor();
|
||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(trace);
|
||||
candidateCall.setTrace(temporaryTrace);
|
||||
@@ -483,9 +483,9 @@ public class CallResolver {
|
||||
recordAutoCastIfNecessary(candidateCall.getThisObject(), candidateCall.getTrace());
|
||||
}
|
||||
|
||||
Set<ResolvedCall<D>> successfulCandidates = Sets.newLinkedHashSet();
|
||||
Set<ResolvedCall<D>> failedCandidates = Sets.newLinkedHashSet();
|
||||
for (ResolvedCall<D> candidateCall : task.getCandidates()) {
|
||||
Set<ResolvedCallImpl<D>> successfulCandidates = Sets.newLinkedHashSet();
|
||||
Set<ResolvedCallImpl<D>> failedCandidates = Sets.newLinkedHashSet();
|
||||
for (ResolvedCallImpl<D> candidateCall : task.getCandidates()) {
|
||||
ResolutionStatus status = candidateCall.getStatus();
|
||||
if (status.isSuccess()) {
|
||||
successfulCandidates.add(candidateCall);
|
||||
@@ -555,7 +555,7 @@ public class CallResolver {
|
||||
// };
|
||||
// }
|
||||
|
||||
private <D extends CallableDescriptor> void replaceValueParametersWithSubstitutedOnes(ResolvedCall<D> candidateCall, @NotNull D substitutedDescriptor) {
|
||||
private <D extends CallableDescriptor> void replaceValueParametersWithSubstitutedOnes(ResolvedCallImpl<D> candidateCall, @NotNull D substitutedDescriptor) {
|
||||
Map<ValueParameterDescriptor, ValueParameterDescriptor> parameterMap = Maps.newHashMap();
|
||||
for (ValueParameterDescriptor valueParameterDescriptor : substitutedDescriptor.getValueParameters()) {
|
||||
parameterMap.put(valueParameterDescriptor.getOriginal(), valueParameterDescriptor);
|
||||
@@ -571,14 +571,14 @@ public class CallResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor> ResolutionStatus checkAllValueArguments(JetScope scope, TracingStrategy tracing, ResolutionTask<D> task, ResolvedCall<D> candidateCall) {
|
||||
private <D extends CallableDescriptor> ResolutionStatus checkAllValueArguments(JetScope scope, TracingStrategy tracing, ResolutionTask<D> task, ResolvedCallImpl<D> candidateCall) {
|
||||
ResolutionStatus result = checkValueArgumentTypes(scope, candidateCall);
|
||||
result = result.combine(checkReceiver(tracing, candidateCall, candidateCall.getResultingDescriptor().getReceiverParameter(), candidateCall.getReceiverArgument(), task));
|
||||
result = result.combine(checkReceiver(tracing, candidateCall, candidateCall.getResultingDescriptor().getExpectedThisObject(), candidateCall.getThisObject(), task));
|
||||
return result;
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor> ResolutionStatus checkReceiver(TracingStrategy tracing, ResolvedCall<D> candidateCall, ReceiverDescriptor receiverParameter, ReceiverDescriptor receiverArgument, ResolutionTask<D> task) {
|
||||
private <D extends CallableDescriptor> ResolutionStatus checkReceiver(TracingStrategy tracing, ResolvedCallImpl<D> candidateCall, ReceiverDescriptor receiverParameter, ReceiverDescriptor receiverArgument, ResolutionTask<D> task) {
|
||||
ResolutionStatus result = SUCCESS;
|
||||
if (receiverParameter.exists() && receiverArgument.exists()) {
|
||||
ASTNode callOperationNode = task.getCall().getCallOperationNode();
|
||||
@@ -606,7 +606,7 @@ public class CallResolver {
|
||||
return result;
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor> ResolutionStatus checkValueArgumentTypes(JetScope scope, ResolvedCall<D> candidateCall) {
|
||||
private <D extends CallableDescriptor> ResolutionStatus checkValueArgumentTypes(JetScope scope, ResolvedCallImpl<D> candidateCall) {
|
||||
ResolutionStatus result = SUCCESS;
|
||||
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : candidateCall.getValueArguments().entrySet()) {
|
||||
ValueParameterDescriptor parameterDescriptor = entry.getKey();
|
||||
@@ -653,16 +653,16 @@ public class CallResolver {
|
||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> computeResultAndReportErrors(
|
||||
BindingTrace trace,
|
||||
TracingStrategy tracing,
|
||||
Set<ResolvedCall<D>> successfulCandidates,
|
||||
Set<ResolvedCall<D>> failedCandidates) {
|
||||
Set<ResolvedCallImpl<D>> successfulCandidates,
|
||||
Set<ResolvedCallImpl<D>> failedCandidates) {
|
||||
// TODO : maybe it's better to filter overrides out first, and only then look for the maximally specific
|
||||
if (successfulCandidates.size() > 0) {
|
||||
return chooseAndReportMaximallySpecific(trace, tracing, successfulCandidates);
|
||||
}
|
||||
else if (!failedCandidates.isEmpty()) {
|
||||
if (failedCandidates.size() != 1) {
|
||||
Set<ResolvedCall<D>> weakErrors = Sets.newLinkedHashSet();
|
||||
for (ResolvedCall<D> candidate : failedCandidates) {
|
||||
Set<ResolvedCallImpl<D>> weakErrors = Sets.newLinkedHashSet();
|
||||
for (ResolvedCallImpl<D> candidate : failedCandidates) {
|
||||
if (candidate.getStatus().isWeakError()) {
|
||||
weakErrors.add(candidate);
|
||||
}
|
||||
@@ -676,7 +676,7 @@ public class CallResolver {
|
||||
return OverloadResolutionResults.manyFailedCandidates(results.getResults());
|
||||
}
|
||||
|
||||
Set<ResolvedCall<D>> noOverrides = OverridingUtil.filterOverrides(failedCandidates, MAP_TO_CANDIDATE);
|
||||
Set<ResolvedCallImpl<D>> noOverrides = OverridingUtil.filterOverrides(failedCandidates, MAP_TO_CANDIDATE);
|
||||
if (noOverrides.size() != 1) {
|
||||
// tracing.reportOverallResolutionError(trace, "None of the following functions can be called with the arguments supplied: "
|
||||
// + makeErrorMessageForMultipleDescriptors(noOverrides));
|
||||
@@ -686,7 +686,7 @@ public class CallResolver {
|
||||
}
|
||||
failedCandidates = noOverrides;
|
||||
}
|
||||
ResolvedCall<D> failed = failedCandidates.iterator().next();
|
||||
ResolvedCallImpl<D> failed = failedCandidates.iterator().next();
|
||||
failed.getTrace().commit();
|
||||
return OverloadResolutionResults.singleFailedCandidate(failed);
|
||||
}
|
||||
@@ -696,12 +696,12 @@ public class CallResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> chooseAndReportMaximallySpecific(BindingTrace trace, TracingStrategy tracing, Set<ResolvedCall<D>> candidates) {
|
||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> chooseAndReportMaximallySpecific(BindingTrace trace, TracingStrategy tracing, Set<ResolvedCallImpl<D>> candidates) {
|
||||
if (candidates.size() != 1) {
|
||||
Set<ResolvedCall<D>> cleanCandidates = Sets.newLinkedHashSet(candidates);
|
||||
Set<ResolvedCallImpl<D>> cleanCandidates = Sets.newLinkedHashSet(candidates);
|
||||
boolean allClean = true;
|
||||
for (Iterator<ResolvedCall<D>> iterator = cleanCandidates.iterator(); iterator.hasNext(); ) {
|
||||
ResolvedCall<D> candidate = iterator.next();
|
||||
for (Iterator<ResolvedCallImpl<D>> iterator = cleanCandidates.iterator(); iterator.hasNext(); ) {
|
||||
ResolvedCallImpl<D> candidate = iterator.next();
|
||||
if (candidate.isDirty()) {
|
||||
iterator.remove();
|
||||
allClean = false;
|
||||
@@ -711,17 +711,17 @@ public class CallResolver {
|
||||
if (cleanCandidates.isEmpty()) {
|
||||
cleanCandidates = candidates;
|
||||
}
|
||||
ResolvedCall<D> maximallySpecific = overloadingConflictResolver.findMaximallySpecific(cleanCandidates, false);
|
||||
ResolvedCallImpl<D> maximallySpecific = overloadingConflictResolver.findMaximallySpecific(cleanCandidates, false);
|
||||
if (maximallySpecific != null) {
|
||||
return OverloadResolutionResults.success(maximallySpecific);
|
||||
}
|
||||
|
||||
ResolvedCall<D> maximallySpecificGenericsDiscriminated = overloadingConflictResolver.findMaximallySpecific(cleanCandidates, true);
|
||||
ResolvedCallImpl<D> maximallySpecificGenericsDiscriminated = overloadingConflictResolver.findMaximallySpecific(cleanCandidates, true);
|
||||
if (maximallySpecificGenericsDiscriminated != null) {
|
||||
return OverloadResolutionResults.success(maximallySpecificGenericsDiscriminated);
|
||||
}
|
||||
|
||||
Set<ResolvedCall<D>> noOverrides = OverridingUtil.filterOverrides(candidates, MAP_TO_RESULT);
|
||||
Set<ResolvedCallImpl<D>> noOverrides = OverridingUtil.filterOverrides(candidates, MAP_TO_RESULT);
|
||||
if (allClean) {
|
||||
// tracing.reportOverallResolutionError(trace, "Overload resolution ambiguity: "
|
||||
// + makeErrorMessageForMultipleDescriptors(noOverrides));
|
||||
@@ -733,7 +733,7 @@ public class CallResolver {
|
||||
return OverloadResolutionResults.ambiguity(noOverrides);
|
||||
}
|
||||
else {
|
||||
ResolvedCall<D> result = candidates.iterator().next();
|
||||
ResolvedCallImpl<D> result = candidates.iterator().next();
|
||||
|
||||
TemporaryBindingTrace temporaryTrace = result.getTrace();
|
||||
temporaryTrace.commit();
|
||||
@@ -762,24 +762,24 @@ public class CallResolver {
|
||||
|
||||
@NotNull
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull JetScope scope, @NotNull ReceiverDescriptor receiver, @NotNull String name, @NotNull List<JetType> parameterTypes) {
|
||||
List<ResolvedCall<FunctionDescriptor>> result = findCandidatesByExactSignature(scope, receiver, name, parameterTypes);
|
||||
List<ResolvedCallImpl<FunctionDescriptor>> result = findCandidatesByExactSignature(scope, receiver, name, parameterTypes);
|
||||
|
||||
BindingTraceContext trace = new BindingTraceContext();
|
||||
TemporaryBindingTrace temporaryBindingTrace = TemporaryBindingTrace.create(trace);
|
||||
Set<ResolvedCall<FunctionDescriptor>> candidates = Sets.newLinkedHashSet();
|
||||
for (ResolvedCall<FunctionDescriptor> call : result) {
|
||||
Set<ResolvedCallImpl<FunctionDescriptor>> candidates = Sets.newLinkedHashSet();
|
||||
for (ResolvedCallImpl<FunctionDescriptor> call : result) {
|
||||
call.setTrace(temporaryBindingTrace);
|
||||
candidates.add(call);
|
||||
}
|
||||
return computeResultAndReportErrors(trace, TracingStrategy.EMPTY, candidates, Collections.<ResolvedCall<FunctionDescriptor>>emptySet());
|
||||
return computeResultAndReportErrors(trace, TracingStrategy.EMPTY, candidates, Collections.<ResolvedCallImpl<FunctionDescriptor>>emptySet());
|
||||
}
|
||||
|
||||
private List<ResolvedCall<FunctionDescriptor>> findCandidatesByExactSignature(JetScope scope, ReceiverDescriptor receiver, String name, List<JetType> parameterTypes) {
|
||||
List<ResolvedCall<FunctionDescriptor>> result = Lists.newArrayList();
|
||||
private List<ResolvedCallImpl<FunctionDescriptor>> findCandidatesByExactSignature(JetScope scope, ReceiverDescriptor receiver, String name, List<JetType> parameterTypes) {
|
||||
List<ResolvedCallImpl<FunctionDescriptor>> result = Lists.newArrayList();
|
||||
if (receiver.exists()) {
|
||||
Collection<ResolvedCall<FunctionDescriptor>> extensionFunctionDescriptors = ResolvedCall.convertCollection(scope.getFunctions(name));
|
||||
List<ResolvedCall<FunctionDescriptor>> nonlocal = Lists.newArrayList();
|
||||
List<ResolvedCall<FunctionDescriptor>> local = Lists.newArrayList();
|
||||
Collection<ResolvedCallImpl<FunctionDescriptor>> extensionFunctionDescriptors = ResolvedCallImpl.convertCollection(scope.getFunctions(name));
|
||||
List<ResolvedCallImpl<FunctionDescriptor>> nonlocal = Lists.newArrayList();
|
||||
List<ResolvedCallImpl<FunctionDescriptor>> local = Lists.newArrayList();
|
||||
TaskPrioritizer.splitLexicallyLocalDescriptors(extensionFunctionDescriptors, scope.getContainingDeclaration(), local, nonlocal);
|
||||
|
||||
|
||||
@@ -787,7 +787,7 @@ public class CallResolver {
|
||||
return result;
|
||||
}
|
||||
|
||||
Collection<ResolvedCall<FunctionDescriptor>> functionDescriptors = ResolvedCall.convertCollection(receiver.getType().getMemberScope().getFunctions(name));
|
||||
Collection<ResolvedCallImpl<FunctionDescriptor>> functionDescriptors = ResolvedCallImpl.convertCollection(receiver.getType().getMemberScope().getFunctions(name));
|
||||
if (lookupExactSignature(functionDescriptors, parameterTypes, result)) {
|
||||
return result;
|
||||
|
||||
@@ -796,14 +796,14 @@ public class CallResolver {
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
lookupExactSignature(ResolvedCall.convertCollection(scope.getFunctions(name)), parameterTypes, result);
|
||||
lookupExactSignature(ResolvedCallImpl.convertCollection(scope.getFunctions(name)), parameterTypes, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean lookupExactSignature(Collection<ResolvedCall<FunctionDescriptor>> candidates, List<JetType> parameterTypes, List<ResolvedCall<FunctionDescriptor>> result) {
|
||||
private boolean lookupExactSignature(Collection<ResolvedCallImpl<FunctionDescriptor>> candidates, List<JetType> parameterTypes, List<ResolvedCallImpl<FunctionDescriptor>> result) {
|
||||
boolean found = false;
|
||||
for (ResolvedCall<FunctionDescriptor> resolvedCall : candidates) {
|
||||
for (ResolvedCallImpl<FunctionDescriptor> resolvedCall : candidates) {
|
||||
FunctionDescriptor functionDescriptor = resolvedCall.getResultingDescriptor();
|
||||
if (functionDescriptor.getReceiverParameter().exists()) continue;
|
||||
if (!functionDescriptor.getTypeParameters().isEmpty()) continue;
|
||||
@@ -814,9 +814,9 @@ public class CallResolver {
|
||||
return found;
|
||||
}
|
||||
|
||||
private boolean findExtensionFunctions(Collection<ResolvedCall<FunctionDescriptor>> candidates, ReceiverDescriptor receiver, List<JetType> parameterTypes, List<ResolvedCall<FunctionDescriptor>> result) {
|
||||
private boolean findExtensionFunctions(Collection<ResolvedCallImpl<FunctionDescriptor>> candidates, ReceiverDescriptor receiver, List<JetType> parameterTypes, List<ResolvedCallImpl<FunctionDescriptor>> result) {
|
||||
boolean found = false;
|
||||
for (ResolvedCall<FunctionDescriptor> resolvedCall : candidates) {
|
||||
for (ResolvedCallImpl<FunctionDescriptor> resolvedCall : candidates) {
|
||||
FunctionDescriptor functionDescriptor = resolvedCall.getResultingDescriptor();
|
||||
ReceiverDescriptor functionReceiver = functionDescriptor.getReceiverParameter();
|
||||
if (!functionReceiver.exists()) continue;
|
||||
|
||||
+9
-9
@@ -29,40 +29,40 @@ public class OverloadResolutionResults<D extends CallableDescriptor> {
|
||||
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> success(@NotNull ResolvedCall<D> descriptor) {
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> success(@NotNull ResolvedCallImpl<D> descriptor) {
|
||||
return new OverloadResolutionResults<D>(Code.SUCCESS, Collections.singleton(descriptor));
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> nameNotFound() {
|
||||
return new OverloadResolutionResults<D>(Code.NAME_NOT_FOUND, Collections.<ResolvedCall<D>>emptyList());
|
||||
return new OverloadResolutionResults<D>(Code.NAME_NOT_FOUND, Collections.<ResolvedCallImpl<D>>emptyList());
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> singleFailedCandidate(ResolvedCall<D> candidate) {
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> singleFailedCandidate(ResolvedCallImpl<D> candidate) {
|
||||
return new OverloadResolutionResults<D>(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate));
|
||||
}
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> manyFailedCandidates(Collection<ResolvedCall<D>> failedCandidates) {
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> manyFailedCandidates(Collection<ResolvedCallImpl<D>> failedCandidates) {
|
||||
return new OverloadResolutionResults<D>(Code.MANY_FAILED_CANDIDATES, failedCandidates);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> ambiguity(Collection<ResolvedCall<D>> descriptors) {
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> ambiguity(Collection<ResolvedCallImpl<D>> descriptors) {
|
||||
return new OverloadResolutionResults<D>(Code.AMBIGUITY, descriptors);
|
||||
}
|
||||
|
||||
private final Collection<ResolvedCall<D>> results;
|
||||
private final Collection<ResolvedCallImpl<D>> results;
|
||||
private final Code resultCode;
|
||||
|
||||
private OverloadResolutionResults(@NotNull Code resultCode, @NotNull Collection<ResolvedCall<D>> results) {
|
||||
private OverloadResolutionResults(@NotNull Code resultCode, @NotNull Collection<ResolvedCallImpl<D>> results) {
|
||||
this.results = results;
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<ResolvedCall<D>> getResults() {
|
||||
public Collection<ResolvedCallImpl<D>> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ResolvedCall<D> getResult() {
|
||||
public ResolvedCallImpl<D> getResult() {
|
||||
assert singleDescriptor();
|
||||
return results.iterator().next();
|
||||
}
|
||||
|
||||
+8
-8
@@ -28,23 +28,23 @@ public class OverloadingConflictResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <D extends CallableDescriptor> ResolvedCall<D> findMaximallySpecific(Set<ResolvedCall<D>> candidates, boolean discriminateGenericDescriptors) {
|
||||
// Different autocasts may lead to the same candidate descriptor wrapped into different ResolvedCall objects
|
||||
Set<ResolvedCall<D>> maximallySpecific = new THashSet<ResolvedCall<D>>(new TObjectHashingStrategy<ResolvedCall<D>>() {
|
||||
public <D extends CallableDescriptor> ResolvedCallImpl<D> findMaximallySpecific(Set<ResolvedCallImpl<D>> candidates, boolean discriminateGenericDescriptors) {
|
||||
// Different autocasts may lead to the same candidate descriptor wrapped into different ResolvedCallImpl objects
|
||||
Set<ResolvedCallImpl<D>> maximallySpecific = new THashSet<ResolvedCallImpl<D>>(new TObjectHashingStrategy<ResolvedCallImpl<D>>() {
|
||||
@Override
|
||||
public boolean equals(ResolvedCall<D> o1, ResolvedCall<D> o2) {
|
||||
public boolean equals(ResolvedCallImpl<D> o1, ResolvedCallImpl<D> o2) {
|
||||
return o1 == null ? o2 == null : o1.getResultingDescriptor().equals(o2.getResultingDescriptor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int computeHashCode(ResolvedCall<D> object) {
|
||||
public int computeHashCode(ResolvedCallImpl<D> object) {
|
||||
return object == null ? 0 : object.getResultingDescriptor().hashCode();
|
||||
}
|
||||
});
|
||||
meLoop:
|
||||
for (ResolvedCall<D> candidateCall : candidates) {
|
||||
for (ResolvedCallImpl<D> candidateCall : candidates) {
|
||||
D me = candidateCall.getResultingDescriptor();
|
||||
for (ResolvedCall<D> otherCall : candidates) {
|
||||
for (ResolvedCallImpl<D> otherCall : candidates) {
|
||||
D other = otherCall.getResultingDescriptor();
|
||||
if (other == me) continue;
|
||||
if (!moreSpecific(me, other, discriminateGenericDescriptors) || moreSpecific(other, me, discriminateGenericDescriptors)) {
|
||||
@@ -54,7 +54,7 @@ public class OverloadingConflictResolver {
|
||||
maximallySpecific.add(candidateCall);
|
||||
}
|
||||
if (maximallySpecific.size() == 1) {
|
||||
ResolvedCall<D> result = maximallySpecific.iterator().next();
|
||||
ResolvedCallImpl<D> result = maximallySpecific.iterator().next();
|
||||
result.getTrace().commit();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ import java.util.Collection;
|
||||
*/
|
||||
/*package*/ class ResolutionTask<D extends CallableDescriptor> {
|
||||
private final Call call;
|
||||
private final Collection<ResolvedCall<D>> candidates;
|
||||
private final Collection<ResolvedCallImpl<D>> candidates;
|
||||
private final DataFlowInfo dataFlowInfo;
|
||||
private DescriptorCheckStrategy checkingStrategy;
|
||||
|
||||
|
||||
public ResolutionTask(
|
||||
@NotNull Collection<ResolvedCall<D>> candidates,
|
||||
@NotNull Collection<ResolvedCallImpl<D>> candidates,
|
||||
@NotNull Call call,
|
||||
@NotNull DataFlowInfo dataFlowInfo
|
||||
) {
|
||||
@@ -34,7 +34,7 @@ import java.util.Collection;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<ResolvedCall<D>> getCandidates() {
|
||||
public Collection<ResolvedCallImpl<D>> getCandidates() {
|
||||
return candidates;
|
||||
}
|
||||
|
||||
|
||||
+18
-11
@@ -21,30 +21,30 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class ResolvedCall<D extends CallableDescriptor> {
|
||||
public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedCallInterface<D> {
|
||||
|
||||
public static final Function<ResolvedCall<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_CANDIDATE = new Function<ResolvedCall<? extends CallableDescriptor>, CallableDescriptor>() {
|
||||
public static final Function<ResolvedCallImpl<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_CANDIDATE = new Function<ResolvedCallImpl<? extends CallableDescriptor>, CallableDescriptor>() {
|
||||
@Override
|
||||
public CallableDescriptor fun(ResolvedCall<? extends CallableDescriptor> resolvedCall) {
|
||||
public CallableDescriptor fun(ResolvedCallImpl<? extends CallableDescriptor> resolvedCall) {
|
||||
return resolvedCall.getCandidateDescriptor();
|
||||
}
|
||||
};
|
||||
|
||||
public static final Function<ResolvedCall<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_RESULT = new Function<ResolvedCall<? extends CallableDescriptor>, CallableDescriptor>() {
|
||||
public static final Function<ResolvedCallImpl<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_RESULT = new Function<ResolvedCallImpl<? extends CallableDescriptor>, CallableDescriptor>() {
|
||||
@Override
|
||||
public CallableDescriptor fun(ResolvedCall<? extends CallableDescriptor> resolvedCall) {
|
||||
public CallableDescriptor fun(ResolvedCallImpl<? extends CallableDescriptor> resolvedCall) {
|
||||
return resolvedCall.getResultingDescriptor();
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
public static <D extends CallableDescriptor> ResolvedCall<D> create(@NotNull D descriptor) {
|
||||
return new ResolvedCall<D>(descriptor);
|
||||
public static <D extends CallableDescriptor> ResolvedCallImpl<D> create(@NotNull D descriptor) {
|
||||
return new ResolvedCallImpl<D>(descriptor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <D extends CallableDescriptor> List<ResolvedCall<D>> convertCollection(@NotNull Collection<D> descriptors) {
|
||||
List<ResolvedCall<D>> result = Lists.newArrayList();
|
||||
public static <D extends CallableDescriptor> List<ResolvedCallImpl<D>> convertCollection(@NotNull Collection<D> descriptors) {
|
||||
List<ResolvedCallImpl<D>> result = Lists.newArrayList();
|
||||
for (D descriptor : descriptors) {
|
||||
result.add(create(descriptor));
|
||||
}
|
||||
@@ -63,10 +63,11 @@ public class ResolvedCall<D extends CallableDescriptor> {
|
||||
private TemporaryBindingTrace trace;
|
||||
private ResolutionStatus status = UNKNOWN_STATUS;
|
||||
|
||||
private ResolvedCall(@NotNull D candidateDescriptor) {
|
||||
private ResolvedCallImpl(@NotNull D candidateDescriptor) {
|
||||
this.candidateDescriptor = candidateDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ResolutionStatus getStatus() {
|
||||
return status;
|
||||
@@ -85,17 +86,19 @@ public class ResolvedCall<D extends CallableDescriptor> {
|
||||
this.trace = trace;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public D getCandidateDescriptor() {
|
||||
return candidateDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public D getResultingDescriptor() {
|
||||
return resultingDescriptor == null ? candidateDescriptor : resultingDescriptor;
|
||||
}
|
||||
|
||||
public ResolvedCall<D> setResultingDescriptor(@NotNull D resultingDescriptor) {
|
||||
public ResolvedCallImpl<D> setResultingDescriptor(@NotNull D resultingDescriptor) {
|
||||
this.resultingDescriptor = resultingDescriptor;
|
||||
return this;
|
||||
}
|
||||
@@ -115,6 +118,7 @@ public class ResolvedCall<D extends CallableDescriptor> {
|
||||
autoCasts.put(parameter, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ReceiverDescriptor getReceiverArgument() {
|
||||
return receiverArgument;
|
||||
@@ -124,6 +128,7 @@ public class ResolvedCall<D extends CallableDescriptor> {
|
||||
this.receiverArgument = receiverParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ReceiverDescriptor getThisObject() {
|
||||
return thisObject;
|
||||
@@ -133,6 +138,7 @@ public class ResolvedCall<D extends CallableDescriptor> {
|
||||
this.thisObject = thisObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<ValueParameterDescriptor, ResolvedValueArgument> getValueArguments() {
|
||||
return valueArguments;
|
||||
@@ -146,6 +152,7 @@ public class ResolvedCall<D extends CallableDescriptor> {
|
||||
return someArgumentHasNoType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<TypeParameterDescriptor, JetType> getTypeArguments() {
|
||||
return typeArguments;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.jetbrains.jet.lang.resolve.calls;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface ResolvedCallInterface<D extends CallableDescriptor> {
|
||||
@NotNull
|
||||
ResolutionStatus getStatus();
|
||||
|
||||
@NotNull
|
||||
D getCandidateDescriptor();
|
||||
|
||||
@NotNull
|
||||
D getResultingDescriptor();
|
||||
|
||||
@NotNull
|
||||
ReceiverDescriptor getReceiverArgument();
|
||||
|
||||
@NotNull
|
||||
ReceiverDescriptor getThisObject();
|
||||
|
||||
@NotNull
|
||||
Map<ValueParameterDescriptor, ResolvedValueArgument> getValueArguments();
|
||||
|
||||
Map<TypeParameterDescriptor, JetType> getTypeArguments();
|
||||
}
|
||||
@@ -29,9 +29,9 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
/*package*/ abstract class TaskPrioritizer<D extends CallableDescriptor> {
|
||||
|
||||
public static <D extends CallableDescriptor> void splitLexicallyLocalDescriptors(
|
||||
Collection<ResolvedCall<D>> allDescriptors, DeclarationDescriptor containerOfTheCurrentLocality, Collection<ResolvedCall<D>> local, Collection<ResolvedCall<D>> nonlocal) {
|
||||
Collection<ResolvedCallImpl<D>> allDescriptors, DeclarationDescriptor containerOfTheCurrentLocality, Collection<ResolvedCallImpl<D>> local, Collection<ResolvedCallImpl<D>> nonlocal) {
|
||||
|
||||
for (ResolvedCall<D> resolvedCall : allDescriptors) {
|
||||
for (ResolvedCallImpl<D> resolvedCall : allDescriptors) {
|
||||
if (isLocal(containerOfTheCurrentLocality, resolvedCall.getCandidateDescriptor())) {
|
||||
local.add(resolvedCall);
|
||||
}
|
||||
@@ -96,13 +96,13 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
if (receiver.exists()) {
|
||||
List<ReceiverDescriptor> variantsForExplicitReceiver = autoCastService.getVariantsForReceiver(receiver);
|
||||
|
||||
Collection<ResolvedCall<D>> extensionFunctions = convertWithImpliedThis(scope, variantsForExplicitReceiver, getExtensionsByName(scope, name));
|
||||
List<ResolvedCall<D>> nonlocals = Lists.newArrayList();
|
||||
List<ResolvedCall<D>> locals = Lists.newArrayList();
|
||||
Collection<ResolvedCallImpl<D>> extensionFunctions = convertWithImpliedThis(scope, variantsForExplicitReceiver, getExtensionsByName(scope, name));
|
||||
List<ResolvedCallImpl<D>> nonlocals = Lists.newArrayList();
|
||||
List<ResolvedCallImpl<D>> locals = Lists.newArrayList();
|
||||
//noinspection unchecked,RedundantTypeArguments
|
||||
TaskPrioritizer.<D>splitLexicallyLocalDescriptors(extensionFunctions, scope.getContainingDeclaration(), locals, nonlocals);
|
||||
|
||||
Collection<ResolvedCall<D>> members = Lists.newArrayList();
|
||||
Collection<ResolvedCallImpl<D>> members = Lists.newArrayList();
|
||||
for (ReceiverDescriptor variant : variantsForExplicitReceiver) {
|
||||
Collection<D> membersForThisVariant = getMembersByName(variant.getType(), name);
|
||||
convertWithReceivers(membersForThisVariant, Collections.singletonList(variant), Collections.singletonList(NO_RECEIVER), members);
|
||||
@@ -120,10 +120,10 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
addTask(result, call, nonlocals, dataFlowInfo);
|
||||
}
|
||||
else {
|
||||
Collection<ResolvedCall<D>> functions = convertWithImpliedThis(scope, Collections.singletonList(receiver), getNonExtensionsByName(scope, name));
|
||||
Collection<ResolvedCallImpl<D>> functions = convertWithImpliedThis(scope, Collections.singletonList(receiver), getNonExtensionsByName(scope, name));
|
||||
|
||||
List<ResolvedCall<D>> nonlocals = Lists.newArrayList();
|
||||
List<ResolvedCall<D>> locals = Lists.newArrayList();
|
||||
List<ResolvedCallImpl<D>> nonlocals = Lists.newArrayList();
|
||||
List<ResolvedCallImpl<D>> locals = Lists.newArrayList();
|
||||
//noinspection unchecked,RedundantTypeArguments
|
||||
TaskPrioritizer.<D>splitLexicallyLocalDescriptors(functions, scope.getContainingDeclaration(), locals, nonlocals);
|
||||
|
||||
@@ -137,18 +137,18 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<ResolvedCall<D>> convertWithReceivers(Collection<D> descriptors, Iterable<ReceiverDescriptor> thisObjects, Iterable<ReceiverDescriptor> receiverParameters) {
|
||||
Collection<ResolvedCall<D>> result = Lists.newArrayList();
|
||||
private Collection<ResolvedCallImpl<D>> convertWithReceivers(Collection<D> descriptors, Iterable<ReceiverDescriptor> thisObjects, Iterable<ReceiverDescriptor> receiverParameters) {
|
||||
Collection<ResolvedCallImpl<D>> result = Lists.newArrayList();
|
||||
convertWithReceivers(descriptors, thisObjects, receiverParameters, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void convertWithReceivers(Collection<D> descriptors, Iterable<ReceiverDescriptor> thisObjects, Iterable<ReceiverDescriptor> receiverParameters, Collection<ResolvedCall<D>> result) {
|
||||
// Collection<ResolvedCall<D>> result = Lists.newArrayList();
|
||||
private void convertWithReceivers(Collection<D> descriptors, Iterable<ReceiverDescriptor> thisObjects, Iterable<ReceiverDescriptor> receiverParameters, Collection<ResolvedCallImpl<D>> result) {
|
||||
// Collection<ResolvedCallImpl<D>> result = Lists.newArrayList();
|
||||
for (ReceiverDescriptor thisObject : thisObjects) {
|
||||
for (ReceiverDescriptor receiverParameter : receiverParameters) {
|
||||
for (D extension : descriptors) {
|
||||
ResolvedCall<D> resolvedCall = ResolvedCall.create(extension);
|
||||
ResolvedCallImpl<D> resolvedCall = ResolvedCallImpl.create(extension);
|
||||
resolvedCall.setThisObject(thisObject);
|
||||
resolvedCall.setReceiverArgument(receiverParameter);
|
||||
result.add(resolvedCall);
|
||||
@@ -158,11 +158,11 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
// return result;
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> Collection<ResolvedCall<D>> convertWithImpliedThis(JetScope scope, Iterable<ReceiverDescriptor> receiverParameters, Collection<D> descriptors) {
|
||||
Collection<ResolvedCall<D>> result = Lists.newArrayList();
|
||||
public static <D extends CallableDescriptor> Collection<ResolvedCallImpl<D>> convertWithImpliedThis(JetScope scope, Iterable<ReceiverDescriptor> receiverParameters, Collection<D> descriptors) {
|
||||
Collection<ResolvedCallImpl<D>> result = Lists.newArrayList();
|
||||
for (ReceiverDescriptor receiverParameter : receiverParameters) {
|
||||
for (D extension : descriptors) {
|
||||
ResolvedCall<D> resolvedCall = ResolvedCall.create(extension);
|
||||
ResolvedCallImpl<D> resolvedCall = ResolvedCallImpl.create(extension);
|
||||
resolvedCall.setReceiverArgument(receiverParameter);
|
||||
if (setImpliedThis(scope, resolvedCall)) {
|
||||
result.add(resolvedCall);
|
||||
@@ -172,7 +172,7 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
return result;
|
||||
}
|
||||
|
||||
private static <D extends CallableDescriptor> boolean setImpliedThis(@NotNull JetScope scope, ResolvedCall<D> resolvedCall) {
|
||||
private static <D extends CallableDescriptor> boolean setImpliedThis(@NotNull JetScope scope, ResolvedCallImpl<D> resolvedCall) {
|
||||
ReceiverDescriptor expectedThisObject = resolvedCall.getCandidateDescriptor().getExpectedThisObject();
|
||||
if (!expectedThisObject.exists()) return true;
|
||||
List<ReceiverDescriptor> receivers = Lists.newArrayList();
|
||||
@@ -187,7 +187,7 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
return false;
|
||||
}
|
||||
|
||||
private void addTask(@NotNull List<ResolutionTask<D>> result, @NotNull Call call, @NotNull Collection<ResolvedCall<D>> candidates, @NotNull DataFlowInfo dataFlowInfo) {
|
||||
private void addTask(@NotNull List<ResolutionTask<D>> result, @NotNull Call call, @NotNull Collection<ResolvedCallImpl<D>> candidates, @NotNull DataFlowInfo dataFlowInfo) {
|
||||
if (candidates.isEmpty()) return;
|
||||
result.add(new ResolutionTask<D>(candidates, call, dataFlowInfo));
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ import java.util.Set;
|
||||
/*package*/ interface TracingStrategy {
|
||||
TracingStrategy EMPTY = new TracingStrategy() {
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall) {}
|
||||
public <D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallImpl<D> resolvedCall) {}
|
||||
|
||||
@Override
|
||||
public void unresolvedReference(@NotNull BindingTrace trace) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCall<D>> candidates) {}
|
||||
public <D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallImpl<D>> candidates) {}
|
||||
|
||||
@Override
|
||||
public void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor expectedReceiver) {}
|
||||
@@ -40,10 +40,10 @@ import java.util.Set;
|
||||
public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Set<ResolvedCall<D>> descriptors) {}
|
||||
public <D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Set<ResolvedCallImpl<D>> descriptors) {}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Set<ResolvedCall<D>> descriptors) {}
|
||||
public <D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Set<ResolvedCallImpl<D>> descriptors) {}
|
||||
|
||||
@Override
|
||||
public void instantiationOfAbstractClass(@NotNull BindingTrace trace) {}
|
||||
@@ -58,11 +58,11 @@ import java.util.Set;
|
||||
public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull JetType type) {}
|
||||
};
|
||||
|
||||
<D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall);
|
||||
<D extends CallableDescriptor> void bindReference(@NotNull BindingTrace trace, @NotNull ResolvedCallImpl<D> resolvedCall);
|
||||
|
||||
void unresolvedReference(@NotNull BindingTrace trace);
|
||||
|
||||
<D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCall<D>> candidates);
|
||||
<D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallImpl<D>> candidates);
|
||||
|
||||
void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor expectedReceiver);
|
||||
|
||||
@@ -74,9 +74,9 @@ import java.util.Set;
|
||||
|
||||
void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount);
|
||||
|
||||
<D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Set<ResolvedCall<D>> descriptors);
|
||||
<D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Set<ResolvedCallImpl<D>> descriptors);
|
||||
|
||||
<D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Set<ResolvedCall<D>> descriptors);
|
||||
<D extends CallableDescriptor> void noneApplicable(@NotNull BindingTrace trace, @NotNull Set<ResolvedCallImpl<D>> descriptors);
|
||||
|
||||
void instantiationOfAbstractClass(@NotNull BindingTrace trace);
|
||||
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
|
||||
public static <D extends CallableDescriptor> boolean mapValueArgumentsToParameters(
|
||||
@NotNull ResolutionTask<D> task,
|
||||
@NotNull TracingStrategy tracing,
|
||||
@NotNull ResolvedCall<D> candidateCall
|
||||
@NotNull ResolvedCallImpl<D> candidateCall
|
||||
) {
|
||||
|
||||
TemporaryBindingTrace temporaryTrace = candidateCall.getTrace();
|
||||
@@ -181,7 +181,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
|
||||
return error;
|
||||
}
|
||||
|
||||
private static <D extends CallableDescriptor> void put(ResolvedCall<D> candidateCall, ValueParameterDescriptor valueParameterDescriptor, ValueArgument valueArgument, Map<ValueParameterDescriptor, VarargValueArgument> varargs) {
|
||||
private static <D extends CallableDescriptor> void put(ResolvedCallImpl<D> candidateCall, ValueParameterDescriptor valueParameterDescriptor, ValueArgument valueArgument, Map<ValueParameterDescriptor, VarargValueArgument> varargs) {
|
||||
if (valueParameterDescriptor.isVararg()) {
|
||||
VarargValueArgument vararg = varargs.get(valueParameterDescriptor);
|
||||
if (vararg == null) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnostic;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.AnalyzerFacade;
|
||||
@@ -92,7 +92,7 @@ public class DebugInfoAnnotator implements Annotator {
|
||||
target = labelTarget.getText();
|
||||
}
|
||||
else {
|
||||
Collection<? extends ResolvedCall<? extends DeclarationDescriptor>> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, expression);
|
||||
Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, expression);
|
||||
if (declarationDescriptors != null) {
|
||||
target = "[" + declarationDescriptors.size() + " descriptors]";
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.plugin.AnalyzerFacade;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -81,7 +81,7 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
||||
if (psiElement != null) {
|
||||
return psiElement;
|
||||
}
|
||||
Collection<? extends ResolvedCall<? extends DeclarationDescriptor>> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
||||
Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
||||
if (declarationDescriptors != null) return null;
|
||||
return file;
|
||||
}
|
||||
@@ -89,11 +89,11 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
||||
protected ResolveResult[] doMultiResolve() {
|
||||
JetFile file = (JetFile) getElement().getContainingFile();
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(file);
|
||||
Collection<? extends ResolvedCall<? extends DeclarationDescriptor>> resolvedCalls = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
||||
Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>> resolvedCalls = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
||||
if (resolvedCalls == null) return ResolveResult.EMPTY_ARRAY;
|
||||
ResolveResult[] results = new ResolveResult[resolvedCalls.size()];
|
||||
int i = 0;
|
||||
for (ResolvedCall<? extends DeclarationDescriptor> resolvedCall : resolvedCalls) {
|
||||
for (ResolvedCallImpl<? extends DeclarationDescriptor> resolvedCall : resolvedCalls) {
|
||||
PsiElement element = bindingContext.get(DESCRIPTOR_TO_DECLARATION, resolvedCall.getResultingDescriptor());
|
||||
if (element != null) {
|
||||
results[i] = new PsiElementResolveResult(element, true);
|
||||
|
||||
@@ -17,9 +17,9 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
@@ -114,7 +114,7 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
||||
CallResolver callResolver = new CallResolver(JetSemanticServices.createSemanticServices(getProject()), DataFlowInfo.EMPTY);
|
||||
OverloadResolutionResults<FunctionDescriptor> functions = callResolver.resolveExactSignature(
|
||||
classDescriptor.getMemberScope(typeArguments), ReceiverDescriptor.NO_RECEIVER, name, parameterTypeList);
|
||||
for (ResolvedCall<FunctionDescriptor> resolvedCall : functions.getResults()) {
|
||||
for (ResolvedCallImpl<FunctionDescriptor> resolvedCall : functions.getResults()) {
|
||||
List<ValueParameterDescriptor> unsubstitutedValueParameters = resolvedCall.getResultingDescriptor().getValueParameters();
|
||||
for (int i = 0, unsubstitutedValueParametersSize = unsubstitutedValueParameters.size(); i < unsubstitutedValueParametersSize; i++) {
|
||||
ValueParameterDescriptor unsubstitutedValueParameter = unsubstitutedValueParameters.get(i);
|
||||
|
||||
Reference in New Issue
Block a user