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 2f8ad2fedb7..ab1b0615d3c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -6,6 +6,7 @@ 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; @@ -47,7 +48,6 @@ 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,10 +266,23 @@ public class CallResolver { @NotNull Call call, @NotNull Collection functionDescriptors ) { - TracingStrategy tracingStrategy = TracingStrategyImpl.create(expression, call); - return resolveCallWithGivenDescriptors( - context, call, functionDescriptors, tracingStrategy, null, null, null + BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS); + + OverloadResolutionResults resolutionResults = PSICallResolver.runResolutionAndInferenceForGivenDescriptors( + callResolutionContext, + functionDescriptors, + TracingStrategyImpl.create(expression, call), + KotlinCallKind.FUNCTION, + 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( @@ -309,35 +322,15 @@ public class CallResolver { @NotNull Call call, @NotNull Collection functionDescriptors ) { - TracingStrategy tracingStrategy = TracingStrategyImpl.create(expression, call); - ReceiverValueWithSmartCastInfo dispatchReceiverValue = - NewResolutionOldInferenceKt.transformToReceiverWithSmartCastInfo(context, receiver); - return resolveCallWithGivenDescriptors( - context, call, functionDescriptors, tracingStrategy, null, null, dispatchReceiverValue - ); - } + BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS); - @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( + OverloadResolutionResults resolutionResults = PSICallResolver.runResolutionAndInferenceForGivenDescriptors( callResolutionContext, - descriptors, - tracingStrategy, + functionDescriptors, + TracingStrategyImpl.create(expression, call), KotlinCallKind.FUNCTION, - substitutor, - dispatchReceiverValue + null, + NewResolutionOldInferenceKt.transformToReceiverWithSmartCastInfo(context, receiver) ); if (resolutionResults.isSingleResult()) { @@ -348,6 +341,29 @@ 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 a0e2ea0ce4c..81f6798f545 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -630,10 +630,15 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { ReceiverParameterDescriptor descriptor, KtExpression expression ) { + BindingTrace trace = context.trace; Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList()); - components.callResolver.resolveCallWithGivenDescriptors( - context, call, Collections.singletonList(descriptor), TracingStrategy.EMPTY, null, null, null - ); + 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); } 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 aeaef9477ed..2d10acd1c8d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java @@ -161,11 +161,17 @@ public class ControlStructureTypingUtils { ) { TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context); TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType, context.languageVersionSettings); - OverloadResolutionResults results = callResolver.resolveCallWithGivenDescriptors( - context, call, Collections.singletonList(function), tracing, knownTypeParameterSubstitutor, dataFlowInfoForArguments, null + OverloadResolutionResults results = callResolver.resolveCallWithGivenDescriptor( + context, call, function, tracing, knownTypeParameterSubstitutor, dataFlowInfoForArguments ); assert results.isSingleResult() : "Not single result after resolving one known candidate"; - return results.getResultingCall(); + + ResolvedCall resolvedCall = results.getResultingCall(); + + context.trace.record(RESOLVED_CALL, call, resolvedCall); + context.trace.record(CALL, call.getCallElement(), call); + + return resolvedCall; } private static @Nullable TypeSubstitutor createKnownTypeParameterSubstitutorForSpecialCall(