From 0c07cb70cae910799a54de5f420edeb5e2a2f978 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 28 Jan 2013 17:18:19 +0400 Subject: [PATCH] BasicResolutionContext renamed to BasicCallResolutionContext --- ...t.java => BasicCallResolutionContext.java} | 19 ++++++------- .../calls/CallCandidateResolutionContext.java | 3 +-- .../resolve/calls/CallResolutionContext.java | 6 ++--- .../jet/lang/resolve/calls/CallResolver.java | 27 ++++++++++--------- .../lang/resolve/calls/CallTransformer.java | 4 +-- .../lang/resolve/calls/ResolutionContext.java | 6 ++--- .../resolve/calls/tasks/ResolutionTask.java | 4 +-- .../calls/tasks/ResolutionTaskHolder.java | 14 +++++----- .../resolve/calls/tasks/TaskPrioritizer.java | 6 ++--- .../expressions/ExpressionTypingContext.java | 11 +++----- 10 files changed, 46 insertions(+), 54 deletions(-) rename compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/{BasicResolutionContext.java => BasicCallResolutionContext.java} (70%) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicCallResolutionContext.java similarity index 70% rename from compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java rename to compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicCallResolutionContext.java index f9e21e2527c..6c5df44f84c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicCallResolutionContext.java @@ -23,9 +23,9 @@ import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.JetType; -public class BasicResolutionContext extends CallResolutionContext { +public class BasicCallResolutionContext extends CallResolutionContext { @NotNull - public static BasicResolutionContext create( + public static BasicCallResolutionContext create( @NotNull BindingTrace trace, @NotNull JetScope scope, @NotNull Call call, @@ -33,20 +33,17 @@ public class BasicResolutionContext extends CallResolutionContext CallCandidateResolutionContext create( - @NotNull CallResolutionContext context, @NotNull TracingStrategy tracing, + @NotNull BasicCallResolutionContext context, @NotNull TracingStrategy tracing, @NotNull ResolvedCallImpl candidateCall) { return new CallCandidateResolutionContext(candidateCall, tracing, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.namespacesAllowed); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java index d984d538748..9f9bc47891e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2012 JetBrains s.r.o. + * Copyright 2010-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public abstract class CallResolutionContext resolveSimpleProperty(@NotNull BasicResolutionContext context) { + public OverloadResolutionResults resolveSimpleProperty(@NotNull BasicCallResolutionContext context) { JetExpression calleeExpression = context.call.getCalleeExpression(); assert calleeExpression instanceof JetSimpleNameExpression; JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) calleeExpression; @@ -107,7 +107,7 @@ public class CallResolver { @NotNull public OverloadResolutionResults resolveCallWithGivenName( - @NotNull BasicResolutionContext context, + @NotNull BasicCallResolutionContext context, @NotNull final JetReferenceExpression functionReference, @NotNull Name name) { List> tasks = @@ -124,11 +124,11 @@ public class CallResolver { @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo ) { - return resolveFunctionCall(BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, false)); + return resolveFunctionCall(BasicCallResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, false)); } @NotNull - public OverloadResolutionResults resolveFunctionCall(@NotNull BasicResolutionContext context) { + public OverloadResolutionResults resolveFunctionCall(@NotNull BasicCallResolutionContext context) { ProgressIndicatorProvider.checkCanceled(); @@ -256,7 +256,7 @@ public class CallResolver { private OverloadResolutionResults doResolveCallOrGetCachedResults( @NotNull WritableSlice> resolutionResultsSlice, - @NotNull final BasicResolutionContext context, + @NotNull final BasicCallResolutionContext context, @NotNull final List> prioritizedTasks, @NotNull CallTransformer callTransformer, @NotNull final JetReferenceExpression reference) { @@ -274,7 +274,7 @@ public class CallResolver { } } if (results == null) { - results = doResolveCall(context.replaceTrace(traceToResolveCall), prioritizedTasks, callTransformer, reference); + results = doResolveCall(context.replaceBindingTrace(traceToResolveCall), prioritizedTasks, callTransformer, reference); if (results instanceof OverloadResolutionResultsImpl) { DelegatingBindingTrace deltasTraceForTypeInference = ((OverloadResolutionResultsImpl) results).getTrace(); if (deltasTraceForTypeInference != null) { @@ -290,13 +290,13 @@ public class CallResolver { } TracingStrategy tracing = prioritizedTasks.iterator().next().tracing; OverloadResolutionResults completeResults = completeTypeInferenceDependentOnExpectedType( - context.replaceTrace(traceToResolveCall), results, tracing); + context.replaceBindingTrace(traceToResolveCall), results, tracing); traceToResolveCall.commit(); return completeResults; } private OverloadResolutionResults completeTypeInferenceDependentOnExpectedType( - @NotNull BasicResolutionContext context, + @NotNull BasicCallResolutionContext context, @NotNull OverloadResolutionResults resultsWithIncompleteTypeInference, @NotNull TracingStrategy tracing ) { @@ -343,7 +343,7 @@ public class CallResolver { } private void cacheResults(@NotNull WritableSlice> resolutionResultsSlice, - @NotNull BasicResolutionContext context, @NotNull OverloadResolutionResults results, + @NotNull BasicCallResolutionContext context, @NotNull OverloadResolutionResults results, @NotNull DelegatingBindingTrace traceToResolveCall) { //boolean canBeCached = true; //for (ResolvedCall call : results.getResultingCalls()) { @@ -364,14 +364,14 @@ public class CallResolver { context.trace.record(TRACE_DELTAS_CACHE, (JetExpression) callElement, deltasTraceToCacheResolve); } - private OverloadResolutionResults checkArgumentTypesAndFail(BasicResolutionContext context) { + private OverloadResolutionResults checkArgumentTypesAndFail(BasicCallResolutionContext context) { argumentTypeResolver.checkTypesWithNoCallee(context); return OverloadResolutionResultsImpl.nameNotFound(); } @NotNull private OverloadResolutionResults doResolveCall( - @NotNull final BasicResolutionContext context, + @NotNull final BasicCallResolutionContext context, @NotNull final List> prioritizedTasks, // high to low priority @NotNull CallTransformer callTransformer, @NotNull final JetReferenceExpression reference) { @@ -390,7 +390,8 @@ public class CallResolver { OverloadResolutionResultsImpl resultsForFirstNonemptyCandidateSet = null; for (ResolutionTask task : prioritizedTasks) { TemporaryBindingTrace taskTrace = TemporaryBindingTrace.create(context.trace, "trace to resolve a task for", task.reference); - OverloadResolutionResultsImpl results = performResolutionGuardedForExtraFunctionLiteralArguments(task.replaceBindingTrace(taskTrace), + OverloadResolutionResultsImpl results = performResolutionGuardedForExtraFunctionLiteralArguments(task.replaceBindingTrace( + taskTrace), callTransformer, context.trace); if (results.isSuccess() || results.isAmbiguity()) { taskTrace.commit(); @@ -427,7 +428,7 @@ public class CallResolver { } private OverloadResolutionResults resolveFunctionArguments( - @NotNull final BasicResolutionContext context, + @NotNull final BasicCallResolutionContext context, @NotNull OverloadResolutionResults results ) { if (results.isSingleResult()) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java index 1c43c3de6d5..c6fc764129a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java @@ -190,11 +190,11 @@ public class CallTransformer { Call functionCall = createFunctionCall(context, task, returnType); final DelegatingBindingTrace variableCallTrace = context.candidateCall.getTrace(); - BasicResolutionContext basicResolutionContext = BasicResolutionContext.create( + BasicCallResolutionContext basicCallResolutionContext = BasicCallResolutionContext.create( variableCallTrace, context.scope, functionCall, context.expectedType, context.dataFlowInfo, context.namespacesAllowed); // 'invoke' call resolve - OverloadResolutionResults results = callResolver.resolveCallWithGivenName(basicResolutionContext, task.reference, Name.identifier("invoke")); + OverloadResolutionResults results = callResolver.resolveCallWithGivenName(basicCallResolutionContext, task.reference, Name.identifier("invoke")); Collection> calls = ((OverloadResolutionResultsImpl)results).getResultingCalls(); return Collections2.transform(calls, new Function, ResolvedCallWithTrace>() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java index 6d61f2e2a9b..30a34d92bd2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java @@ -2,7 +2,7 @@ * Copyright 2010-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use self() file except in compliance with the License. + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 @@ -88,7 +88,7 @@ public abstract class ResolutionContext { } @NotNull - public BasicResolutionContext toCallResolutionContext(@NotNull Call call) { - return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed); + public BasicCallResolutionContext toCallResolutionContext(@NotNull Call call) { + return BasicCallResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed); } } \ No newline at end of file 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 49f02dc2df2..846774e9630 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 @@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingTrace; -import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext; +import org.jetbrains.jet.lang.resolve.calls.BasicCallResolutionContext; import org.jetbrains.jet.lang.resolve.calls.CallResolutionContext; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem; @@ -66,7 +66,7 @@ public class ResolutionTask extends C this.reference = reference; } - public ResolutionTask(@NotNull Collection> candidates, @NotNull JetReferenceExpression reference, @NotNull BasicResolutionContext context) { + public ResolutionTask(@NotNull Collection> candidates, @NotNull JetReferenceExpression reference, @NotNull BasicCallResolutionContext context) { this(candidates, reference, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.namespacesAllowed); } 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 496b9cd7dbd..e3d26cf8423 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 @@ -25,14 +25,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.psi.JetReferenceExpression; -import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext; +import org.jetbrains.jet.lang.resolve.calls.BasicCallResolutionContext; import java.util.Collection; import java.util.List; public class ResolutionTaskHolder { private final JetReferenceExpression reference; - private final BasicResolutionContext basicResolutionContext; + private final BasicCallResolutionContext basicCallResolutionContext; private final Predicate> visibleStrategy; private final boolean isSafeCall; @@ -43,12 +43,12 @@ public class ResolutionTaskHolder { private List> tasks = null; public ResolutionTaskHolder(@NotNull JetReferenceExpression reference, - @NotNull BasicResolutionContext basicResolutionContext, + @NotNull BasicCallResolutionContext basicCallResolutionContext, @NotNull Predicate> visibleStrategy) { this.reference = reference; - this.basicResolutionContext = basicResolutionContext; + this.basicCallResolutionContext = basicCallResolutionContext; this.visibleStrategy = visibleStrategy; - this.isSafeCall = JetPsiUtil.isSafeCall(basicResolutionContext.call); + this.isSafeCall = JetPsiUtil.isSafeCall(basicCallResolutionContext.call); } public Collection> setIsSafeCall(@NotNull Collection> candidates) { @@ -83,7 +83,7 @@ public class ResolutionTaskHolder { // If the call is of the form super.foo(), it can actually be only a member // But if there's no appropriate member, we would like to report that super cannot be a receiver for an extension // Thus, put members first - if (TaskPrioritizer.getReceiverSuper(basicResolutionContext.call.getExplicitReceiver()) != null) { + if (TaskPrioritizer.getReceiverSuper(basicCallResolutionContext.call.getExplicitReceiver()) != null) { candidateList.addAll(members); candidateList.addAll(localExtensions); } @@ -97,7 +97,7 @@ public class ResolutionTaskHolder { for (Collection> candidates : candidateList) { Collection> filteredCandidates = Collections2.filter(candidates, visibilityStrategy); if (!filteredCandidates.isEmpty()) { - tasks.add(new ResolutionTask(filteredCandidates, reference, basicResolutionContext)); + tasks.add(new ResolutionTask(filteredCandidates, reference, basicCallResolutionContext)); } } } 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 5a751977b0b..cc57e41bc67 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 @@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.psi.JetSuperExpression; import org.jetbrains.jet.lang.resolve.DescriptorUtils; -import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext; +import org.jetbrains.jet.lang.resolve.calls.BasicCallResolutionContext; import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastServiceImpl; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; @@ -75,7 +75,7 @@ public abstract class TaskPrioritizer { } @NotNull - public static List> computePrioritizedTasks(@NotNull BasicResolutionContext context, @NotNull Name name, + public static List> computePrioritizedTasks(@NotNull BasicCallResolutionContext context, @NotNull Name name, @NotNull JetReferenceExpression functionReference, @NotNull List> callableDescriptorCollectors) { ReceiverValue explicitReceiver = context.call.getExplicitReceiver(); final JetScope scope; @@ -106,7 +106,7 @@ public abstract class TaskPrioritizer { private static void doComputeTasks(@NotNull JetScope scope, @NotNull ReceiverValue receiver, @NotNull Name name, @NotNull ResolutionTaskHolder result, - @NotNull BasicResolutionContext context, @NotNull CallableDescriptorCollector callableDescriptorCollector) { + @NotNull BasicCallResolutionContext context, @NotNull CallableDescriptorCollector callableDescriptorCollector) { ProgressIndicatorProvider.checkCanceled(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java index 574109a575f..5d50f8505ac 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java @@ -22,11 +22,10 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.psi.Call; -import org.jetbrains.jet.lang.psi.JetQualifiedExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; import org.jetbrains.jet.lang.resolve.BindingTrace; -import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext; +import org.jetbrains.jet.lang.resolve.calls.BasicCallResolutionContext; import org.jetbrains.jet.lang.resolve.calls.ResolutionContext; import org.jetbrains.jet.lang.resolve.calls.util.CallMaker; import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults; @@ -36,10 +35,6 @@ import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.jet.lang.types.JetType; -import org.jetbrains.jet.lang.types.JetTypeInfo; -import org.jetbrains.jet.lang.types.TypeUtils; - -import java.util.List; public class ExpressionTypingContext extends ResolutionContext { @@ -113,8 +108,8 @@ public class ExpressionTypingContext extends ResolutionContext