Proper resolved calls in loop ranges

This commit is contained in:
Andrey Breslav
2012-08-23 18:46:16 +04:00
parent 784bf31a3e
commit e13fa067cc
3 changed files with 8 additions and 7 deletions
@@ -1132,6 +1132,7 @@ public class CallResolver {
} }
} }
@Deprecated // Creates wrong resolved calls, should be removed
@NotNull @NotNull
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull JetScope scope, @NotNull ReceiverDescriptor receiver, @NotNull Name name, @NotNull List<JetType> parameterTypes) { public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull JetScope scope, @NotNull ReceiverDescriptor receiver, @NotNull Name name, @NotNull List<JetType> parameterTypes) {
List<ResolutionCandidate<FunctionDescriptor>> candidates = findCandidatesByExactSignature(scope, receiver, name, parameterTypes); List<ResolutionCandidate<FunctionDescriptor>> candidates = findCandidatesByExactSignature(scope, receiver, name, parameterTypes);
@@ -384,11 +384,10 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
@NotNull String name, @NotNull String name,
@NotNull SimpleDiagnosticFactory<JetExpression> ambiguity, @NotNull SimpleDiagnosticFactory<JetExpression> ambiguity,
@NotNull SimpleDiagnosticFactory<JetExpression> missing, @NotNull SimpleDiagnosticFactory<JetExpression> missing,
@NotNull WritableSlice<JetExpression, ResolvedCall<FunctionDescriptor>> call @NotNull WritableSlice<JetExpression, ResolvedCall<FunctionDescriptor>> resolvedCallKey
) { ) {
OverloadResolutionResults<FunctionDescriptor> OverloadResolutionResults<FunctionDescriptor> nextResolutionResults = resolveFakeCall(
nextResolutionResults = context.resolveExactSignature(new TransientReceiver(iteratorType), Name.identifier(name), Collections new TransientReceiver(iteratorType), context, Name.identifier(name));
.<JetType>emptyList());
if (nextResolutionResults.isAmbiguity()) { if (nextResolutionResults.isAmbiguity()) {
context.trace.report(ambiguity.on(loopRangeExpression)); context.trace.report(ambiguity.on(loopRangeExpression));
} }
@@ -396,9 +395,9 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
context.trace.report(missing.on(loopRangeExpression)); context.trace.report(missing.on(loopRangeExpression));
} }
else { else {
ResolvedCall<FunctionDescriptor> nextCall = nextResolutionResults.getResultingCall(); ResolvedCall<FunctionDescriptor> resolvedCall = nextResolutionResults.getResultingCall();
context.trace.record(call, loopRangeExpression, nextCall); context.trace.record(resolvedCallKey, loopRangeExpression, resolvedCall);
return nextCall.getResultingDescriptor().getReturnType(); return resolvedCall.getResultingDescriptor().getReturnType();
} }
return null; return null;
} }
@@ -174,6 +174,7 @@ public class ExpressionTypingContext {
return expressionTypingServices.getCallResolver().resolveSimpleProperty(makeResolutionContext(call)); return expressionTypingServices.getCallResolver().resolveSimpleProperty(makeResolutionContext(call));
} }
@Deprecated // Builds wrong resolved calls, should be removed
@NotNull @NotNull
public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull ReceiverDescriptor receiver, @NotNull Name name, @NotNull List<JetType> parameterTypes) { public OverloadResolutionResults<FunctionDescriptor> resolveExactSignature(@NotNull ReceiverDescriptor receiver, @NotNull Name name, @NotNull List<JetType> parameterTypes) {
return expressionTypingServices.getCallResolver().resolveExactSignature(scope, receiver, name, parameterTypes); return expressionTypingServices.getCallResolver().resolveExactSignature(scope, receiver, name, parameterTypes);