KT-5773 Smart cast doesn't work with Nothing on the rhs of "?:"
#KT-5773 FIxed
This commit is contained in:
+4
@@ -1064,6 +1064,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType rightType = rightTypeInfo.getType();
|
||||
|
||||
DataFlowInfo dataFlowInfo = resolvedCall.getDataFlowInfoForArguments().getResultInfo();
|
||||
if (leftType != null && rightType != null && KotlinBuiltIns.getInstance().isNothingOrNullableNothing(rightType) && !rightType.isNullable()) {
|
||||
DataFlowValue value = DataFlowValueFactory.createDataFlowValue(left, leftType, context.trace.getBindingContext());
|
||||
dataFlowInfo = dataFlowInfo.disequate(value, DataFlowValue.NULL);
|
||||
}
|
||||
JetType type = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
if (type == null || rightType == null) return JetTypeInfo.create(null, dataFlowInfo);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user