Fix JetType.equals(): flexible types are not equal to non-flexible ones, when we store them in a HashSet

This commit is contained in:
Andrey Breslav
2014-10-07 14:05:55 +04:00
parent 5be4dda58b
commit e418a763db
12 changed files with 89 additions and 8 deletions
@@ -1081,7 +1081,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
JetType type = resolvedCall.getResultingDescriptor().getReturnType();
if (type == null || rightType == null) return JetTypeInfo.create(null, dataFlowInfo);
return JetTypeInfo.create(TypeUtils.makeNullableAsSpecified(type, rightType.isNullable()), dataFlowInfo);
// Sometimes return type for special call for elvis operator might be nullable,
// but result is not nullable if the right type is not nullable
if (!TypeUtils.isNullableType(rightType) && TypeUtils.isNullableType(type)) {
type = TypeUtils.makeNotNullable(type);
}
return JetTypeInfo.create(type, dataFlowInfo);
}
@NotNull