cond-expr: use the mobile type instead of the original type

This commit is contained in:
Lu Guanqun
2016-01-22 17:14:01 +00:00
parent c8b0533933
commit d36537e737
2 changed files with 37 additions and 13 deletions
+3 -12
View File
@@ -751,19 +751,10 @@ bool TypeChecker::visit(Conditional const& _conditional)
_conditional.trueExpression().accept(*this);
_conditional.falseExpression().accept(*this);
TypePointer const& trueType = type(_conditional.trueExpression());
TypePointer const& falseType = type(_conditional.falseExpression());
TypePointer trueType = type(_conditional.trueExpression())->mobileType();
TypePointer falseType = type(_conditional.falseExpression())->mobileType();
TypePointer commonType;
if (*trueType == *falseType)
commonType = trueType;
else
{
commonType = Type::commonType(trueType, falseType);
if (!commonType)
// we fake it as an equal operator, but any other comparison operator can work.
commonType = trueType->binaryOperatorResult(Token::Equal, falseType);
}
TypePointer commonType = Type::commonType(trueType, falseType);
if (!commonType)
{
typeError(