[NI] Do not calculate lambda return type in Visitor if NI enabled.

This commit is contained in:
Stanislav Erokhin
2017-05-24 21:53:51 +03:00
committed by Mikhail Zarechenskiy
parent 85248676d2
commit 42438bd363
2 changed files with 5 additions and 4 deletions
@@ -109,9 +109,7 @@ class KotlinResolutionCallbacksImpl(
trace.record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, ktFunction, LambdaInfo.STUB_EMPTY)
val lastExpressionArgument = getLastDeparentesizedExpression(psiCallArgument)?.let { lastExpression ->
val lastExpressionType = functionTypeInfo.type?.let {
if (it.isFunctionType) it.getReturnTypeFromFunctionType() else it
}
val lastExpressionType = trace.getType(lastExpression)
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, lambdaInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
createCallArgument(lastExpression, lastExpressionTypeInfo)
}
@@ -225,7 +225,10 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
val blockReturnedType = components.expressionTypingServices.getBlockReturnedType(functionLiteral.bodyExpression!!, COERCION_TO_UNIT, newContext)
val typeOfBodyExpression = blockReturnedType.type
context.trace[BindingContext.NEW_INFERENCE_LAMBDA_INFO, expression.functionLiteral]?.dataFlowInfoAfter = blockReturnedType.dataFlowInfo
context.trace[BindingContext.NEW_INFERENCE_LAMBDA_INFO, expression.functionLiteral]?.let {
it.dataFlowInfoAfter = blockReturnedType.dataFlowInfo
return null
}
return computeReturnTypeBasedOnReturnExpressions(functionLiteral, context, typeOfBodyExpression)
}