From 5ec97093fa064a690e844db5b6d247f3c8cdbba0 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Mon, 20 Sep 2021 16:43:27 +0300 Subject: [PATCH] Propagate tracing strategy for creating callable reference arguments --- .../tower/KotlinResolutionCallbacksImpl.kt | 3 ++- .../resolve/calls/tower/PSICallResolver.kt | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt index 42585b37aab..43f82172048 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt @@ -118,7 +118,8 @@ class KotlinResolutionCallbacksImpl( newContext, deparenthesizedExpression, DataFlowInfo.EMPTY, CallMaker.makeExternalValueArgument(deparenthesizedExpression), argumentName = null, - outerCallContext + outerCallContext, + tracingStrategy = TracingStrategyImpl.create(deparenthesizedExpression.callableReference, newContext.call) ) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt index a1dddc27948..06bfdbbe0e6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt @@ -581,7 +581,8 @@ class PSICallResolver( val argumentsInParenthesis = if (extraArgumentsNumber == 0) allValueArguments else allValueArguments.dropLast(extraArgumentsNumber) val externalLambdaArguments = oldCall.functionLiteralArguments - val resolvedArgumentsInParenthesis = resolveArgumentsInParenthesis(context, argumentsInParenthesis, isSpecialFunction) + val resolvedArgumentsInParenthesis = + resolveArgumentsInParenthesis(context, argumentsInParenthesis, isSpecialFunction, tracingStrategy) val externalArgument = if (oldCall.callType == Call.CallType.ARRAY_SET_METHOD) { assert(externalLambdaArguments.isEmpty()) { @@ -615,8 +616,9 @@ class PSICallResolver( else context.dataFlowInfoForArguments.resultInfo - val resolvedExternalArgument = - externalArgument?.let { resolveValueArgument(context, dataFlowInfoAfterArgumentsInParenthesis, it, isSpecialFunction) } + val resolvedExternalArgument = externalArgument?.let { + resolveValueArgument(context, dataFlowInfoAfterArgumentsInParenthesis, it, isSpecialFunction, tracingStrategy) + } val resultDataFlowInfo = resolvedExternalArgument?.dataFlowInfoAfterThisArgument ?: dataFlowInfoAfterArgumentsInParenthesis resolvedArgumentsInParenthesis.forEach { it.setResultDataFlowInfoIfRelevant(resultDataFlowInfo) } @@ -699,7 +701,8 @@ class PSICallResolver( private fun resolveArgumentsInParenthesis( context: BasicCallResolutionContext, arguments: List, - isSpecialFunction: Boolean + isSpecialFunction: Boolean, + tracingStrategy: TracingStrategy, ): List { val dataFlowInfoForArguments = context.dataFlowInfoForArguments return arguments.map { argument -> @@ -707,7 +710,8 @@ class PSICallResolver( context, dataFlowInfoForArguments.getInfo(argument), argument, - isSpecialFunction + isSpecialFunction, + tracingStrategy ).also { resolvedArgument -> dataFlowInfoForArguments.updateInfo(argument, resolvedArgument.dataFlowInfoAfterThisArgument) } @@ -718,7 +722,8 @@ class PSICallResolver( outerCallContext: BasicCallResolutionContext, startDataFlowInfo: DataFlowInfo, valueArgument: ValueArgument, - isSpecialFunction: Boolean + isSpecialFunction: Boolean, + tracingStrategy: TracingStrategy, ): PSIKotlinCallArgument { val builtIns = outerCallContext.scope.ownerDescriptor.builtIns @@ -760,13 +765,13 @@ class PSICallResolver( if (ktExpression is KtCallableReferenceExpression) { return createCallableReferenceKotlinCallArgument( - context, ktExpression, startDataFlowInfo, valueArgument, argumentName, - outerCallContext + context, ktExpression, startDataFlowInfo, valueArgument, argumentName, outerCallContext, tracingStrategy ) } // argumentExpression instead of ktExpression is hack -- type info should be stored also for parenthesized expression val typeInfo = expressionTypingServices.getTypeInfo(argumentExpression, context) + return createSimplePSICallArgument(context, valueArgument, typeInfo) ?: createParseErrorElement() }