From 85e34163bbc243afbdfc613f58e9b927d16733cd Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Tue, 20 Jun 2017 13:17:42 +0300 Subject: [PATCH] [NI] Temporary fix for cases related callable reference and if For cases like if (..) ::foo else ::bar we didn't write stub resolved calls for ::foo before call completion. Because of this, and strange code in if we get null inside type info. --- .../jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt index 22ca63e0f3c..4b30b66bf0c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt @@ -191,7 +191,10 @@ internal fun createSimplePSICallArgument( val onlyResolvedCall = ktExpression.getCall(bindingContext)?.let { bindingContext.get(BindingContext.ONLY_RESOLVED_CALL, it) } - val baseType = typeInfoForArgument.type?.unwrap() ?: return null + // todo hack for if expression: sometimes we not write properly type information for branches + val baseType = typeInfoForArgument.type?.unwrap() ?: + onlyResolvedCall?.candidate?.lastCall?.descriptorWithFreshTypes?.returnType?.unwrap() ?: + return null // we should use DFI after this argument, because there can be some useful smartcast. Popular case: if branches. val receiverToCast = transformToReceiverWithSmartCastInfo(