Control-Flow Analysis: Use PSI to generate pseudocode if nested resolved call is confused with outer one (e.g. a {} when invoke() is missing)

#KT-14500 Fixed
This commit is contained in:
Alexey Sedunov
2016-11-02 16:15:07 +03:00
parent e8b5387384
commit a414843f54
9 changed files with 103 additions and 8 deletions
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.lexer.KtTokens.*
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingContextUtils
import org.jetbrains.kotlin.resolve.BindingTrace
@@ -1466,7 +1467,10 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
}
private fun generateCall(callElement: KtElement): Boolean {
return checkAndGenerateCall(callElement.getResolvedCall(trace.bindingContext))
val resolvedCall = callElement.getResolvedCall(trace.bindingContext)
val callElementFromResolvedCall = resolvedCall?.call?.callElement ?: return false
if (callElement.isAncestor(callElementFromResolvedCall, true)) return false
return checkAndGenerateCall(resolvedCall)
}
private fun checkAndGenerateCall(resolvedCall: ResolvedCall<*>?): Boolean {