diff options
author | chriseth <chris@ethereum.org> | 2017-08-11 16:56:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-11 16:56:13 +0800 |
commit | c84de7fa63d34dde03aa97c6ff1101c56202c880 (patch) | |
tree | bea40f791197f4c6d85273f6eb5084318cb2db6d /libsolidity | |
parent | abe6eb983073d5a8e6d5ac469e4c437ea421c79d (diff) | |
parent | ad7a63f8908241ead63be8687e5ec457cc56d1e8 (diff) | |
download | dexon-solidity-c84de7fa63d34dde03aa97c6ff1101c56202c880.tar dexon-solidity-c84de7fa63d34dde03aa97c6ff1101c56202c880.tar.gz dexon-solidity-c84de7fa63d34dde03aa97c6ff1101c56202c880.tar.bz2 dexon-solidity-c84de7fa63d34dde03aa97c6ff1101c56202c880.tar.lz dexon-solidity-c84de7fa63d34dde03aa97c6ff1101c56202c880.tar.xz dexon-solidity-c84de7fa63d34dde03aa97c6ff1101c56202c880.tar.zst dexon-solidity-c84de7fa63d34dde03aa97c6ff1101c56202c880.zip |
Merge pull request #2724 from ethereum/function-type-payable
Check for payable when comparing function types
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ast/Types.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index cf43d3fe..8af60317 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -2220,6 +2220,8 @@ string FunctionType::identifier() const } if (isConstant()) id += "_constant"; + if (isPayable()) + id += "_payable"; id += identifierList(m_parameterTypes) + "returns" + identifierList(m_returnParameterTypes); if (m_gasSet) id += "gas"; @@ -2234,23 +2236,22 @@ bool FunctionType::operator==(Type const& _other) const { if (_other.category() != category()) return false; - FunctionType const& other = dynamic_cast<FunctionType const&>(_other); - if (m_kind != other.m_kind) - return false; - if (m_isConstant != other.isConstant()) + FunctionType const& other = dynamic_cast<FunctionType const&>(_other); + if ( + m_kind != other.m_kind || + m_isConstant != other.isConstant() || + m_isPayable != other.isPayable() || + m_parameterTypes.size() != other.m_parameterTypes.size() || + m_returnParameterTypes.size() != other.m_returnParameterTypes.size() + ) return false; - if (m_parameterTypes.size() != other.m_parameterTypes.size() || - m_returnParameterTypes.size() != other.m_returnParameterTypes.size()) - return false; auto typeCompare = [](TypePointer const& _a, TypePointer const& _b) -> bool { return *_a == *_b; }; - - if (!equal(m_parameterTypes.cbegin(), m_parameterTypes.cend(), - other.m_parameterTypes.cbegin(), typeCompare)) - return false; - if (!equal(m_returnParameterTypes.cbegin(), m_returnParameterTypes.cend(), - other.m_returnParameterTypes.cbegin(), typeCompare)) + if ( + !equal(m_parameterTypes.cbegin(), m_parameterTypes.cend(), other.m_parameterTypes.cbegin(), typeCompare) || + !equal(m_returnParameterTypes.cbegin(), m_returnParameterTypes.cend(), other.m_returnParameterTypes.cbegin(), typeCompare) + ) return false; //@todo this is ugly, but cannot be prevented right now if (m_gasSet != other.m_gasSet || m_valueSet != other.m_valueSet) @@ -2399,10 +2400,15 @@ FunctionTypePointer FunctionType::interfaceFunctionType() const return FunctionTypePointer(); return make_shared<FunctionType>( - paramTypes, retParamTypes, - m_parameterNames, m_returnParameterNames, - m_kind, m_arbitraryParameters, - m_declaration, m_isConstant, m_isPayable + paramTypes, + retParamTypes, + m_parameterNames, + m_returnParameterNames, + m_kind, + m_arbitraryParameters, + m_declaration, + m_isConstant, + m_isPayable ); } |