From b336919db3577e59b7a3c55b894d22412f39e1fc Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 8 Jun 2017 18:41:10 +0300 Subject: [PATCH] [NI] In NI mode, use return type from special call resolution for '!!' --- .../types/expressions/BasicExpressionTypingVisitor.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index d184841322d..f03a3e1c714 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.*; import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt; import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver; import org.jetbrains.kotlin.resolve.calls.CallExpressionResolver; +import org.jetbrains.kotlin.resolve.calls.KotlinResolutionConfigurationKt; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.checkers.*; import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl; @@ -823,7 +824,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { // See also CallExpressionResolver.getSimpleNameExpressionTypeInfo, .getQualifiedExpressionTypeInfo Call call = createCallForSpecialConstruction( expression, expression.getOperationReference(), Collections.singletonList(baseExpression)); - components.controlStructureTypingUtils.resolveSpecialConstructionAsCall( + ResolvedCall resolvedCall = components.controlStructureTypingUtils.resolveSpecialConstructionAsCall( call, ResolveConstruct.EXCL_EXCL, Collections.singletonList("baseExpr"), Collections.singletonList(true), context, null); KotlinTypeInfo baseTypeInfo = BindingContextUtils.getRecordedTypeInfo(baseExpression, context.trace.getBindingContext()); @@ -852,7 +853,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { baseTypeInfo = baseTypeInfo.replaceDataFlowInfo(dataFlowInfo.disequate(value, DataFlowValue.nullValue(components.builtIns), components.languageVersionSettings)); } - KotlinType resultingType = TypeUtils.makeNotNullable(baseType); + KotlinType resultingType = KotlinResolutionConfigurationKt.getUSE_NEW_INFERENCE() + ? resolvedCall.getResultingDescriptor().getReturnType() + : TypeUtils.makeNotNullable(baseType); if (context.contextDependency == DEPENDENT) { return baseTypeInfo.replaceType(resultingType); }