[NI] Fix COERCION_TO_UNIT in NI.
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
de17604fe7
commit
e12eb66572
+3
-2
@@ -17,8 +17,6 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
@@ -46,6 +44,7 @@ import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
|
||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
class KotlinResolutionCallbacksImpl(
|
||||
@@ -109,6 +108,8 @@ class KotlinResolutionCallbacksImpl(
|
||||
trace.record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, ktFunction, LambdaInfo.STUB_EMPTY)
|
||||
|
||||
val lastExpressionArgument = getLastDeparentesizedExpression(psiCallArgument)?.let { lastExpression ->
|
||||
if (expectedReturnType?.isUnit() == true) return@let null // coercion to Unit
|
||||
|
||||
val lastExpressionType = trace.getType(lastExpression)
|
||||
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, lambdaInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
|
||||
createCallArgument(lastExpression, lastExpressionTypeInfo)
|
||||
|
||||
+8
-1
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.KotlinResolutionConfigurationKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
@@ -309,7 +310,13 @@ public class ExpressionTypingServices {
|
||||
expectedType = context.expectedType;
|
||||
}
|
||||
|
||||
return blockLevelVisitor.getTypeInfo(statementExpression, context.replaceExpectedType(expectedType), true);
|
||||
ContextDependency dependency = context.contextDependency;
|
||||
if (KotlinResolutionConfigurationKt.getUSE_NEW_INFERENCE()) {
|
||||
dependency = ContextDependency.INDEPENDENT;
|
||||
|
||||
}
|
||||
|
||||
return blockLevelVisitor.getTypeInfo(statementExpression, context.replaceExpectedType(expectedType).replaceContextDependency(dependency), true);
|
||||
}
|
||||
KotlinTypeInfo result = blockLevelVisitor.getTypeInfo(statementExpression, context, true);
|
||||
if (coercionStrategyForLastExpression == COERCION_TO_UNIT) {
|
||||
|
||||
Reference in New Issue
Block a user