From 5d2ae9aec51c3955d17cd3f3ee850054eccfb404 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Thu, 25 Jul 2013 17:44:39 +0400 Subject: [PATCH] added ability to resolve call with uncustomary tracing strategy (necessary for special 'tracing for if') --- .../jet/lang/resolve/calls/CallResolver.java | 2 +- .../resolve/calls/tasks/ResolutionTask.java | 19 +++++++++++++++++-- .../calls/tasks/ResolutionTaskHolder.java | 7 +++++-- .../resolve/calls/tasks/TaskPrioritizer.java | 8 +++++--- 4 files changed, 28 insertions(+), 8 deletions(-) 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 f31c1c21ff8..16d91912ca6 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 @@ -206,7 +206,7 @@ public class CallResolver { } Collection> candidates = TaskPrioritizer.convertWithImpliedThis(context.scope, Collections.singletonList(NO_RECEIVER), constructors); prioritizedTasks = TaskPrioritizer.computePrioritizedTasksFromCandidates( - context, functionReference, candidates); + context, functionReference, candidates, null); } else { context.trace.report(NOT_A_CLASS.on(calleeExpression)); 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 72cc8f92b77..b87c8ffc449 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 @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.calls.tasks; import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.psi.Call; import org.jetbrains.jet.lang.psi.JetReferenceExpression; @@ -53,12 +54,26 @@ public class ResolutionTask extends C this.tracing = tracing; } - public ResolutionTask(@NotNull Collection> candidates, @NotNull JetReferenceExpression reference, @NotNull BasicCallResolutionContext context) { - this(candidates, reference, TracingStrategyImpl.create(reference, context.call), context.trace, context.scope, context.call, + public ResolutionTask( + @NotNull Collection> candidates, + @NotNull JetReferenceExpression reference, + @NotNull BasicCallResolutionContext context, + @Nullable TracingStrategy tracing + ) { + this(candidates, reference, tracing != null ? tracing : TracingStrategyImpl.create(reference, context.call), + context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.resolveMode, context.checkArguments, context.expressionPosition, context.resolutionResultsCache); } + public ResolutionTask( + @NotNull Collection> candidates, + @NotNull JetReferenceExpression reference, + @NotNull BasicCallResolutionContext context + ) { + this(candidates, reference, context, null); + } + @NotNull public Collection> getCandidates() { return candidates; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTaskHolder.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTaskHolder.java index 5533913bb59..3ce08b229c1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTaskHolder.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTaskHolder.java @@ -34,6 +34,7 @@ public class ResolutionTaskHolder { private final JetReferenceExpression reference; private final BasicCallResolutionContext basicCallResolutionContext; private final PriorityProvider> priorityProvider; + private final TracingStrategy tracing; private final boolean isSafeCall; private final Collection>> candidatesList = Lists.newArrayList(); @@ -42,11 +43,13 @@ public class ResolutionTaskHolder { public ResolutionTaskHolder(@NotNull JetReferenceExpression reference, @NotNull BasicCallResolutionContext basicCallResolutionContext, - @NotNull PriorityProvider> priorityProvider + @NotNull PriorityProvider> priorityProvider, + @Nullable TracingStrategy tracing ) { this.reference = reference; this.basicCallResolutionContext = basicCallResolutionContext; this.priorityProvider = priorityProvider; + this.tracing = tracing; this.isSafeCall = JetPsiUtil.isSafeCall(basicCallResolutionContext.call); } @@ -83,7 +86,7 @@ public class ResolutionTaskHolder { } }); if (!filteredCandidates.isEmpty()) { - tasks.add(new ResolutionTask(filteredCandidates, reference, basicCallResolutionContext)); + tasks.add(new ResolutionTask(filteredCandidates, reference, basicCallResolutionContext, tracing)); } } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java index e2d2788afc7..561396fcf62 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java @@ -92,7 +92,7 @@ public class TaskPrioritizer { scope = context.scope; } - ResolutionTaskHolder result = new ResolutionTaskHolder(functionReference, context, new MyPriorityProvider(context)); + ResolutionTaskHolder result = new ResolutionTaskHolder(functionReference, context, new MyPriorityProvider(context), null); TaskPrioritizerContext c = new TaskPrioritizerContext(name, result, context, scope, callableDescriptorCollectors); doComputeTasks(explicitReceiver, c); return result.getTasks(); @@ -337,9 +337,11 @@ public class TaskPrioritizer { public static List> computePrioritizedTasksFromCandidates( @NotNull BasicCallResolutionContext context, @NotNull JetReferenceExpression functionReference, - @NotNull Collection> candidates + @NotNull Collection> candidates, + @Nullable TracingStrategy tracing ) { - ResolutionTaskHolder result = new ResolutionTaskHolder(functionReference, context, new MyPriorityProvider(context)); + ResolutionTaskHolder result = new ResolutionTaskHolder( + functionReference, context, new MyPriorityProvider(context), tracing); result.addCandidates(candidates); return result.getTasks(); }