[NI] Fix hierarchy of resolution atoms for lambda with non-local return

This commit is contained in:
Mikhail Zarechenskiy
2017-12-11 17:22:26 +03:00
parent c6d8b39b4f
commit 9eca8cd451
6 changed files with 60 additions and 9 deletions
@@ -123,18 +123,17 @@ class KotlinResolutionCallbacksImpl(
}
}
if (!hasReturnWithoutExpression) {
val lastExpressionArgument = getLastDeparentesizedExpression(psiCallArgument)?.let { lastExpression ->
if (expectedReturnType?.isUnit() == true) return@let null // coercion to Unit
val lastExpressionArgument = getLastDeparentesizedExpression(psiCallArgument)?.let { lastExpression ->
if (expectedReturnType?.isUnit() == true) return@let null // coercion to Unit
// todo lastExpression can be if without else
val lastExpressionType = trace.getType(lastExpression)
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, lambdaInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
createCallArgument(lastExpression, lastExpressionTypeInfo)
}
returnArguments.addIfNotNull(lastExpressionArgument)
// todo lastExpression can be if without else
val lastExpressionType = if (hasReturnWithoutExpression) null else trace.getType(lastExpression)
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, lambdaInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
createCallArgument(lastExpression, lastExpressionTypeInfo)
}
returnArguments.addIfNotNull(lastExpressionArgument)
return returnArguments
}