From e4b73fcdbdd3912e4567fc7e24f2ff7363f530f5 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Thu, 8 Jun 2017 12:24:52 +0300 Subject: [PATCH] [NI] Create SubCallArgument for variable in VariableAsFunctionCall If variable is generic call, then we should complete inference only after invoke resolution. It means that explicit receiver for invoke should be SubKotlinCallArgument. But, if this property has no generics, for example local property, then this property can have smartcast and such call has no type arguments -> no completion required. For such call we should store information about smart casts. --- .../kotlin/resolve/calls/tower/PSICallResolver.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 f6a6024884d..b97b84ebec4 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 @@ -345,8 +345,17 @@ class PSICallResolver( } // todo: review - private fun createReceiverCallArgument(variable: SimpleKotlinResolutionCandidate): ExpressionKotlinCallArgument = - ReceiverExpressionKotlinCallArgument(createReceiverValueWithSmartCastInfo(variable), isVariableReceiverForInvoke = true) + private fun createReceiverCallArgument(variable: SimpleKotlinResolutionCandidate): SimpleKotlinCallArgument { + val variableReceiver = createReceiverValueWithSmartCastInfo(variable) + if (variableReceiver.possibleTypes.isNotEmpty()) { + return ReceiverExpressionKotlinCallArgument(createReceiverValueWithSmartCastInfo(variable), isVariableReceiverForInvoke = true) + } + + val psiKotlinCall = variable.kotlinCall.psiKotlinCall + return SubKotlinCallArgumentImpl(CallMaker.makeExternalValueArgument((variableReceiver.receiverValue as ExpressionReceiver).expression), + psiKotlinCall.resultDataFlowInfo, psiKotlinCall.resultDataFlowInfo, variableReceiver, + ResolvedKotlinCall.OnlyResolvedKotlinCall(variable)) + } // todo: decrease hacks count private fun createReceiverValueWithSmartCastInfo(variable: SimpleKotlinResolutionCandidate): ReceiverValueWithSmartCastInfo {