From 42438bd3633dda1ba1ef53a274ca0e30f22b0216 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 24 May 2017 21:53:51 +0300 Subject: [PATCH] [NI] Do not calculate lambda return type in Visitor if NI enabled. --- .../resolve/calls/tower/KotlinResolutionCallbacksImpl.kt | 4 +--- .../kotlin/types/expressions/FunctionsTypingVisitor.kt | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt index 5e77e7ce7d1..0761dbabe24 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt @@ -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) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt index 8ec2a1ee4f4..e956879ac34 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt @@ -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) }