KT-5773 Smart cast doesn't work with Nothing on the rhs of "?:"

#KT-5773 FIxed
This commit is contained in:
Andrey Breslav
2014-09-15 18:24:13 +04:00
parent 3a806713fd
commit f1cf446e10
3 changed files with 21 additions and 0 deletions
@@ -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);