Type checker: move the burden of computing mobile type to commonType

This solves #621
This commit is contained in:
Yoichi Hirai 2016-10-26 15:57:42 +02:00
parent 33590d513e
commit 6c15757618
No known key found for this signature in database
GPG Key ID: E7B75D080FCF7992
2 changed files with 6 additions and 6 deletions

View File

@ -996,9 +996,9 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
fatalTypeError(components[i]->location(), "Invalid mobile type.");
if (i == 0)
inlineArrayType = types[i]->mobileType();
inlineArrayType = types[i];
else if (inlineArrayType)
inlineArrayType = Type::commonType(inlineArrayType, types[i]->mobileType());
inlineArrayType = Type::commonType(inlineArrayType, types[i]);
}
}
else

View File

@ -200,10 +200,10 @@ TypePointer Type::commonType(TypePointer const& _a, TypePointer const& _b)
{
if (!_a || !_b)
return TypePointer();
else if (_b->isImplicitlyConvertibleTo(*_a))
return _a;
else if (_a->isImplicitlyConvertibleTo(*_b))
return _b;
else if (_b->isImplicitlyConvertibleTo(*_a->mobileType()))
return _a->mobileType();
else if (_a->isImplicitlyConvertibleTo(*_b->mobileType()))
return _b->mobileType();
else
return TypePointer();
}