diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index ab1b0615d3c..2f8ad2fedb7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.resolve.calls; import com.intellij.psi.PsiElement; -import kotlin.collections.CollectionsKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.FunctionTypesKt; @@ -48,6 +47,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope; import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes; import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; +import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo; import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.KotlinTypeKt; import org.jetbrains.kotlin.types.TypeSubstitutor; @@ -266,23 +266,10 @@ public class CallResolver { @NotNull Call call, @NotNull Collection functionDescriptors ) { - BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS); - - OverloadResolutionResults resolutionResults = PSICallResolver.runResolutionAndInferenceForGivenDescriptors( - callResolutionContext, - functionDescriptors, - TracingStrategyImpl.create(expression, call), - KotlinCallKind.FUNCTION, - null, - null + TracingStrategy tracingStrategy = TracingStrategyImpl.create(expression, call); + return resolveCallWithGivenDescriptors( + context, call, functionDescriptors, tracingStrategy, null, null, null ); - - if (resolutionResults.isSingleResult()) { - context.trace.record(BindingContext.RESOLVED_CALL, call, resolutionResults.getResultingCall()); - context.trace.record(BindingContext.CALL, call.getCallElement(), call); - } - - return resolutionResults; } public OverloadResolutionResults resolveSetterCall( @@ -322,15 +309,35 @@ public class CallResolver { @NotNull Call call, @NotNull Collection functionDescriptors ) { - BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS); + TracingStrategy tracingStrategy = TracingStrategyImpl.create(expression, call); + ReceiverValueWithSmartCastInfo dispatchReceiverValue = + NewResolutionOldInferenceKt.transformToReceiverWithSmartCastInfo(context, receiver); + return resolveCallWithGivenDescriptors( + context, call, functionDescriptors, tracingStrategy, null, null, dispatchReceiverValue + ); + } - OverloadResolutionResults resolutionResults = PSICallResolver.runResolutionAndInferenceForGivenDescriptors( + @NotNull + public OverloadResolutionResults resolveCallWithGivenDescriptors( + @NotNull ExpressionTypingContext context, + @NotNull Call call, + @NotNull Collection descriptors, + @NotNull TracingStrategy tracingStrategy, + @Nullable TypeSubstitutor substitutor, + @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments, + @Nullable ReceiverValueWithSmartCastInfo dispatchReceiverValue + ) { + BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create( + context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments + ); + + OverloadResolutionResults resolutionResults = PSICallResolver.runResolutionAndInferenceForGivenDescriptors( callResolutionContext, - functionDescriptors, - TracingStrategyImpl.create(expression, call), + descriptors, + tracingStrategy, KotlinCallKind.FUNCTION, - null, - NewResolutionOldInferenceKt.transformToReceiverWithSmartCastInfo(context, receiver) + substitutor, + dispatchReceiverValue ); if (resolutionResults.isSingleResult()) { @@ -341,29 +348,6 @@ public class CallResolver { return resolutionResults; } - @NotNull - public OverloadResolutionResults resolveCallWithGivenDescriptor( - @NotNull ExpressionTypingContext context, - @NotNull Call call, - @NotNull D descriptor, - @NotNull TracingStrategy tracingStrategy, - @Nullable TypeSubstitutor substitutor, - @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments - ) { - BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create( - context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments - ); - - return PSICallResolver.runResolutionAndInferenceForGivenDescriptors( - callResolutionContext, - Collections.singletonList(descriptor), - tracingStrategy, - KotlinCallKind.FUNCTION, - substitutor, - null - ); - } - @NotNull public OverloadResolutionResults resolveFunctionCall( @NotNull BindingTrace trace, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 81f6798f545..a0e2ea0ce4c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -630,15 +630,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { ReceiverParameterDescriptor descriptor, KtExpression expression ) { - BindingTrace trace = context.trace; Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList()); - OverloadResolutionResults results = - components.callResolver.resolveCallWithGivenDescriptor(context, call, descriptor, TracingStrategy.EMPTY, null, null); - - ResolvedCall resolvedCall = results.getResultingCall(); - - trace.record(RESOLVED_CALL, call, resolvedCall); - trace.record(CALL, expression, call); + components.callResolver.resolveCallWithGivenDescriptors( + context, call, Collections.singletonList(descriptor), TracingStrategy.EMPTY, null, null, null + ); } private static boolean isDeclaredInClass(ReceiverParameterDescriptor receiver) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java index 2d10acd1c8d..aeaef9477ed 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java @@ -161,17 +161,11 @@ public class ControlStructureTypingUtils { ) { TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context); TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType, context.languageVersionSettings); - OverloadResolutionResults results = callResolver.resolveCallWithGivenDescriptor( - context, call, function, tracing, knownTypeParameterSubstitutor, dataFlowInfoForArguments + OverloadResolutionResults results = callResolver.resolveCallWithGivenDescriptors( + context, call, Collections.singletonList(function), tracing, knownTypeParameterSubstitutor, dataFlowInfoForArguments, null ); assert results.isSingleResult() : "Not single result after resolving one known candidate"; - - ResolvedCall resolvedCall = results.getResultingCall(); - - context.trace.record(RESOLVED_CALL, call, resolvedCall); - context.trace.record(CALL, call.getCallElement(), call); - - return resolvedCall; + return results.getResultingCall(); } private static @Nullable TypeSubstitutor createKnownTypeParameterSubstitutorForSpecialCall(