refactoring
extracted variables added method 'replaceCall' to ResolutionTask removed unused parameter
This commit is contained in:
@@ -403,7 +403,7 @@ public class CallResolver {
|
||||
for (ResolutionTask<D, F> task : prioritizedTasks) {
|
||||
TemporaryBindingTrace taskTrace = TemporaryBindingTrace.create(context.trace, "trace to resolve a task for", task.reference);
|
||||
OverloadResolutionResultsImpl<F> results = performResolutionGuardedForExtraFunctionLiteralArguments(
|
||||
task.replaceBindingTrace(taskTrace), callTransformer, context.trace);
|
||||
task.replaceBindingTrace(taskTrace), callTransformer);
|
||||
if (results.isSuccess() || results.isAmbiguity()) {
|
||||
taskTrace.commit();
|
||||
|
||||
@@ -456,9 +456,9 @@ public class CallResolver {
|
||||
@NotNull
|
||||
private <D extends CallableDescriptor, F extends D> OverloadResolutionResultsImpl<F> performResolutionGuardedForExtraFunctionLiteralArguments(
|
||||
@NotNull ResolutionTask<D, F> task,
|
||||
@NotNull CallTransformer<D, F> callTransformer,
|
||||
@NotNull BindingTrace traceForResolutionCache) {
|
||||
OverloadResolutionResultsImpl<F> results = performResolution(task, callTransformer, traceForResolutionCache);
|
||||
@NotNull CallTransformer<D, F> callTransformer
|
||||
) {
|
||||
OverloadResolutionResultsImpl<F> results = performResolution(task, callTransformer);
|
||||
|
||||
// If resolution fails, we should check for some of the following situations:
|
||||
// class A {
|
||||
@@ -482,17 +482,18 @@ public class CallResolver {
|
||||
// We have some candidates that failed for some reason
|
||||
// And we have a suspect: the function literal argument
|
||||
// Now, we try to remove this argument and see if it helps
|
||||
ResolutionTask<D, F> newTask = new ResolutionTask<D, F>(task.getCandidates(), task.reference, task.tracing,
|
||||
TemporaryBindingTrace.create(task.trace, "trace for resolution guarded for extra function literal arguments"),
|
||||
task.scope, new DelegatingCall(task.call) {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetExpression> getFunctionLiteralArguments() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}, task.expectedType, task.dataFlowInfo, task.resolveMode, task.checkArguments,
|
||||
task.expressionPosition, task.resolutionResultsCache);
|
||||
OverloadResolutionResultsImpl<F> resultsWithFunctionLiteralsStripped = performResolution(newTask, callTransformer, traceForResolutionCache);
|
||||
DelegatingCall callWithoutFLArgs = new DelegatingCall(task.call) {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetExpression> getFunctionLiteralArguments() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
TemporaryBindingTrace temporaryTrace =
|
||||
TemporaryBindingTrace.create(task.trace, "trace for resolution guarded for extra function literal arguments");
|
||||
ResolutionTask<D, F> newTask = task.replaceBindingTrace(temporaryTrace).replaceCall(callWithoutFLArgs);
|
||||
|
||||
OverloadResolutionResultsImpl<F> resultsWithFunctionLiteralsStripped = performResolution(newTask, callTransformer);
|
||||
if (resultsWithFunctionLiteralsStripped.isSuccess() || resultsWithFunctionLiteralsStripped.isAmbiguity()) {
|
||||
task.tracing.danglingFunctionLiteralArgumentSuspected(task.trace, task.call.getFunctionLiteralArguments());
|
||||
}
|
||||
@@ -504,8 +505,8 @@ public class CallResolver {
|
||||
@NotNull
|
||||
private <D extends CallableDescriptor, F extends D> OverloadResolutionResultsImpl<F> performResolution(
|
||||
@NotNull ResolutionTask<D, F> task,
|
||||
@NotNull CallTransformer<D, F> callTransformer,
|
||||
@NotNull BindingTrace traceForResolutionCache) {
|
||||
@NotNull CallTransformer<D, F> callTransformer
|
||||
) {
|
||||
|
||||
for (ResolutionCandidate<D> resolutionCandidate : task.getCandidates()) {
|
||||
TemporaryBindingTrace candidateTrace = TemporaryBindingTrace.create(
|
||||
|
||||
@@ -100,6 +100,12 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends C
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResolutionTask<D, F> replaceCall(@NotNull Call newCall) {
|
||||
return new ResolutionTask<D, F>(
|
||||
candidates, reference, tracing, trace, scope, newCall, expectedType, dataFlowInfo, resolveMode, checkArguments,
|
||||
expressionPosition, resolutionResultsCache);
|
||||
}
|
||||
|
||||
public interface DescriptorCheckStrategy {
|
||||
<D extends CallableDescriptor> boolean performAdvancedChecks(D descriptor, BindingTrace trace, TracingStrategy tracing);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user