diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-12 20:39:12 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-12 20:39:12 +0800 |
commit | a62d3fa24060016f7c1faaa2ab211d692a2b6359 (patch) | |
tree | 6e9ab7a211ac1793d50a98b120f622bf1d64b774 /Types.cpp | |
parent | 3b54583d380886de57b0668bab4fff8cfa298b8c (diff) | |
download | dexon-solidity-a62d3fa24060016f7c1faaa2ab211d692a2b6359.tar.gz dexon-solidity-a62d3fa24060016f7c1faaa2ab211d692a2b6359.tar.zst dexon-solidity-a62d3fa24060016f7c1faaa2ab211d692a2b6359.zip |
Some fixes on Types.cpp for FixedBytesType
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -231,7 +231,7 @@ TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointe // All integer types can be compared if (Token::isCompareOp(_operator)) return commonType; - // Nothing else can be done with addresses, but hashes can receive bit operators + // Nothing else can be done with addresses if (commonType->isAddress()) return TypePointer(); @@ -282,16 +282,17 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) bool IntegerConstantType::isImplicitlyConvertibleTo(Type const& _convertTo) const { - auto integerType = getIntegerType(); + shared_ptr<IntegerType const> integerType = getIntegerType(); + if (!integerType) + return false; + if (_convertTo.getCategory() == Category::FixedBytes) { FixedBytesType const& convertTo = dynamic_cast<FixedBytesType const&>(_convertTo); - if (convertTo.getNumBytes() * 8 >= integerType->getNumBits()) - return true; - return false; + return convertTo.getNumBytes() * 8 >= integerType->getNumBits(); } - - return integerType && integerType->isImplicitlyConvertibleTo(_convertTo); + + return integerType->isImplicitlyConvertibleTo(_convertTo); } bool IntegerConstantType::isExplicitlyConvertibleTo(Type const& _convertTo) const @@ -462,8 +463,6 @@ bool FixedBytesType::isImplicitlyConvertibleTo(Type const& _convertTo) const bool FixedBytesType::isExplicitlyConvertibleTo(Type const& _convertTo) const { - if (_convertTo.getCategory() == getCategory()) - return true; if (_convertTo.getCategory() == Category::Integer) { IntegerType const& convertTo = dynamic_cast<IntegerType const&>(_convertTo); @@ -471,7 +470,8 @@ bool FixedBytesType::isExplicitlyConvertibleTo(Type const& _convertTo) const return true; } - return false; + return _convertTo.getCategory() == Category::Contract || + _convertTo.getCategory() == getCategory(); } TypePointer FixedBytesType::unaryOperatorResult(Token::Value _operator) const |