Propagate tracing strategy for creating callable reference arguments

This commit is contained in:
Victor Petukhov
2021-09-20 16:43:27 +03:00
parent 764361bc42
commit 5ec97093fa
2 changed files with 15 additions and 9 deletions
@@ -118,7 +118,8 @@ class KotlinResolutionCallbacksImpl(
newContext, deparenthesizedExpression, DataFlowInfo.EMPTY, newContext, deparenthesizedExpression, DataFlowInfo.EMPTY,
CallMaker.makeExternalValueArgument(deparenthesizedExpression), CallMaker.makeExternalValueArgument(deparenthesizedExpression),
argumentName = null, argumentName = null,
outerCallContext outerCallContext,
tracingStrategy = TracingStrategyImpl.create(deparenthesizedExpression.callableReference, newContext.call)
) )
} }
@@ -581,7 +581,8 @@ class PSICallResolver(
val argumentsInParenthesis = if (extraArgumentsNumber == 0) allValueArguments else allValueArguments.dropLast(extraArgumentsNumber) val argumentsInParenthesis = if (extraArgumentsNumber == 0) allValueArguments else allValueArguments.dropLast(extraArgumentsNumber)
val externalLambdaArguments = oldCall.functionLiteralArguments 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) { val externalArgument = if (oldCall.callType == Call.CallType.ARRAY_SET_METHOD) {
assert(externalLambdaArguments.isEmpty()) { assert(externalLambdaArguments.isEmpty()) {
@@ -615,8 +616,9 @@ class PSICallResolver(
else else
context.dataFlowInfoForArguments.resultInfo context.dataFlowInfoForArguments.resultInfo
val resolvedExternalArgument = val resolvedExternalArgument = externalArgument?.let {
externalArgument?.let { resolveValueArgument(context, dataFlowInfoAfterArgumentsInParenthesis, it, isSpecialFunction) } resolveValueArgument(context, dataFlowInfoAfterArgumentsInParenthesis, it, isSpecialFunction, tracingStrategy)
}
val resultDataFlowInfo = resolvedExternalArgument?.dataFlowInfoAfterThisArgument ?: dataFlowInfoAfterArgumentsInParenthesis val resultDataFlowInfo = resolvedExternalArgument?.dataFlowInfoAfterThisArgument ?: dataFlowInfoAfterArgumentsInParenthesis
resolvedArgumentsInParenthesis.forEach { it.setResultDataFlowInfoIfRelevant(resultDataFlowInfo) } resolvedArgumentsInParenthesis.forEach { it.setResultDataFlowInfoIfRelevant(resultDataFlowInfo) }
@@ -699,7 +701,8 @@ class PSICallResolver(
private fun resolveArgumentsInParenthesis( private fun resolveArgumentsInParenthesis(
context: BasicCallResolutionContext, context: BasicCallResolutionContext,
arguments: List<ValueArgument>, arguments: List<ValueArgument>,
isSpecialFunction: Boolean isSpecialFunction: Boolean,
tracingStrategy: TracingStrategy,
): List<KotlinCallArgument> { ): List<KotlinCallArgument> {
val dataFlowInfoForArguments = context.dataFlowInfoForArguments val dataFlowInfoForArguments = context.dataFlowInfoForArguments
return arguments.map { argument -> return arguments.map { argument ->
@@ -707,7 +710,8 @@ class PSICallResolver(
context, context,
dataFlowInfoForArguments.getInfo(argument), dataFlowInfoForArguments.getInfo(argument),
argument, argument,
isSpecialFunction isSpecialFunction,
tracingStrategy
).also { resolvedArgument -> ).also { resolvedArgument ->
dataFlowInfoForArguments.updateInfo(argument, resolvedArgument.dataFlowInfoAfterThisArgument) dataFlowInfoForArguments.updateInfo(argument, resolvedArgument.dataFlowInfoAfterThisArgument)
} }
@@ -718,7 +722,8 @@ class PSICallResolver(
outerCallContext: BasicCallResolutionContext, outerCallContext: BasicCallResolutionContext,
startDataFlowInfo: DataFlowInfo, startDataFlowInfo: DataFlowInfo,
valueArgument: ValueArgument, valueArgument: ValueArgument,
isSpecialFunction: Boolean isSpecialFunction: Boolean,
tracingStrategy: TracingStrategy,
): PSIKotlinCallArgument { ): PSIKotlinCallArgument {
val builtIns = outerCallContext.scope.ownerDescriptor.builtIns val builtIns = outerCallContext.scope.ownerDescriptor.builtIns
@@ -760,13 +765,13 @@ class PSICallResolver(
if (ktExpression is KtCallableReferenceExpression) { if (ktExpression is KtCallableReferenceExpression) {
return createCallableReferenceKotlinCallArgument( return createCallableReferenceKotlinCallArgument(
context, ktExpression, startDataFlowInfo, valueArgument, argumentName, context, ktExpression, startDataFlowInfo, valueArgument, argumentName, outerCallContext, tracingStrategy
outerCallContext
) )
} }
// argumentExpression instead of ktExpression is hack -- type info should be stored also for parenthesized expression // argumentExpression instead of ktExpression is hack -- type info should be stored also for parenthesized expression
val typeInfo = expressionTypingServices.getTypeInfo(argumentExpression, context) val typeInfo = expressionTypingServices.getTypeInfo(argumentExpression, context)
return createSimplePSICallArgument(context, valueArgument, typeInfo) ?: createParseErrorElement() return createSimplePSICallArgument(context, valueArgument, typeInfo) ?: createParseErrorElement()
} }