'resolveExactSignature' removed
This commit is contained in:
@@ -519,92 +519,4 @@ public class CallResolver {
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// to be removed
|
||||
|
||||
@Deprecated // Creates wrong resolved calls, should be removed
|
||||
@NotNull
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull JetScope scope, @NotNull ReceiverValue receiver, @NotNull Name name, @NotNull List<JetType> parameterTypes) {
|
||||
List<ResolutionCandidate<FunctionDescriptor>> candidates = findCandidatesByExactSignature(scope, receiver, name, parameterTypes);
|
||||
|
||||
BindingTraceContext trace = new BindingTraceContext();
|
||||
TemporaryBindingTrace temporaryBindingTrace = TemporaryBindingTrace.create(trace, "trace for resolve exact signature call", name);
|
||||
Set<ResolvedCallWithTrace<FunctionDescriptor>> calls = Sets.newLinkedHashSet();
|
||||
for (ResolutionCandidate<FunctionDescriptor> candidate : candidates) {
|
||||
ResolvedCallImpl<FunctionDescriptor> call = ResolvedCallImpl.create(candidate, temporaryBindingTrace);
|
||||
calls.add(call);
|
||||
}
|
||||
return resolutionResultsHandler.computeResultAndReportErrors(trace, TracingStrategy.EMPTY, calls,
|
||||
Collections.<ResolvedCallWithTrace<FunctionDescriptor>>emptySet());
|
||||
}
|
||||
|
||||
private List<ResolutionCandidate<FunctionDescriptor>> findCandidatesByExactSignature(JetScope scope, ReceiverValue receiver,
|
||||
Name name, List<JetType> parameterTypes) {
|
||||
List<ResolutionCandidate<FunctionDescriptor>> result = Lists.newArrayList();
|
||||
if (receiver.exists()) {
|
||||
Collection<ResolutionCandidate<FunctionDescriptor>> extensionFunctionDescriptors = ResolutionCandidate.convertCollection(scope.getFunctions(name), false);
|
||||
List<ResolutionCandidate<FunctionDescriptor>> nonlocal = Lists.newArrayList();
|
||||
List<ResolutionCandidate<FunctionDescriptor>> local = Lists.newArrayList();
|
||||
TaskPrioritizer.splitLexicallyLocalDescriptors(extensionFunctionDescriptors, scope.getContainingDeclaration(), local, nonlocal);
|
||||
|
||||
|
||||
if (findExtensionFunctions(local, receiver, parameterTypes, result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Collection<ResolutionCandidate<FunctionDescriptor>> functionDescriptors = ResolutionCandidate.convertCollection(receiver.getType().getMemberScope().getFunctions(name), false);
|
||||
if (lookupExactSignature(functionDescriptors, parameterTypes, result)) {
|
||||
return result;
|
||||
|
||||
}
|
||||
findExtensionFunctions(nonlocal, receiver, parameterTypes, result);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
lookupExactSignature(ResolutionCandidate.convertCollection(scope.getFunctions(name), false), parameterTypes, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean lookupExactSignature(Collection<ResolutionCandidate<FunctionDescriptor>> candidates, List<JetType> parameterTypes,
|
||||
List<ResolutionCandidate<FunctionDescriptor>> result) {
|
||||
boolean found = false;
|
||||
for (ResolutionCandidate<FunctionDescriptor> resolvedCall : candidates) {
|
||||
FunctionDescriptor functionDescriptor = resolvedCall.getDescriptor();
|
||||
if (functionDescriptor.getReceiverParameter() != null) continue;
|
||||
if (!functionDescriptor.getTypeParameters().isEmpty()) continue;
|
||||
if (!checkValueParameters(functionDescriptor, parameterTypes)) continue;
|
||||
result.add(resolvedCall);
|
||||
found = true;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
private boolean findExtensionFunctions(Collection<ResolutionCandidate<FunctionDescriptor>> candidates, ReceiverValue receiver,
|
||||
List<JetType> parameterTypes, List<ResolutionCandidate<FunctionDescriptor>> result) {
|
||||
boolean found = false;
|
||||
for (ResolutionCandidate<FunctionDescriptor> candidate : candidates) {
|
||||
FunctionDescriptor functionDescriptor = candidate.getDescriptor();
|
||||
ReceiverParameterDescriptor functionReceiver = functionDescriptor.getReceiverParameter();
|
||||
if (functionReceiver == null) continue;
|
||||
if (!functionDescriptor.getTypeParameters().isEmpty()) continue;
|
||||
if (!typeChecker.isSubtypeOf(receiver.getType(), functionReceiver.getType())) continue;
|
||||
if (!checkValueParameters(functionDescriptor, parameterTypes))continue;
|
||||
result.add(candidate);
|
||||
found = true;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
private static boolean checkValueParameters(@NotNull FunctionDescriptor functionDescriptor, @NotNull List<JetType> parameterTypes) {
|
||||
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
|
||||
if (valueParameters.size() != parameterTypes.size()) return false;
|
||||
for (int i = 0; i < valueParameters.size(); i++) {
|
||||
ValueParameterDescriptor valueParameter = valueParameters.get(i);
|
||||
JetType expectedType = parameterTypes.get(i);
|
||||
if (!TypeUtils.equalTypes(expectedType, valueParameter.getType())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
-6
@@ -164,10 +164,4 @@ public class ExpressionTypingContext {
|
||||
Call call = CallMaker.makePropertyCall(receiver, callOperationNode, nameExpression);
|
||||
return expressionTypingServices.getCallResolver().resolveSimpleProperty(makeResolutionContext(call));
|
||||
}
|
||||
|
||||
@Deprecated // Builds wrong resolved calls, should be removed
|
||||
@NotNull
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull ReceiverValue receiver, @NotNull Name name, @NotNull List<JetType> parameterTypes) {
|
||||
return expressionTypingServices.getCallResolver().resolveExactSignature(scope, receiver, name, parameterTypes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user