diff options
author | chriseth <chris@ethereum.org> | 2017-01-24 18:52:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-24 18:52:21 +0800 |
commit | b52a60402d0885f8700658488b02bc48f7746aaf (patch) | |
tree | 6a497d0fb97fef96e409893e3c7fa938a4795e6c /libsolidity | |
parent | c5a501addd2c339621af76db86bcf87c7111fc8d (diff) | |
parent | 4e1fd68b38346ec3e4117dc0454b65f4b236741b (diff) | |
download | dexon-solidity-b52a60402d0885f8700658488b02bc48f7746aaf.tar.gz dexon-solidity-b52a60402d0885f8700658488b02bc48f7746aaf.tar.zst dexon-solidity-b52a60402d0885f8700658488b02bc48f7746aaf.zip |
Merge pull request #1245 from ethereum/1215
Allow multiple events of the same name
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/DeclarationContainer.cpp | 22 | ||||
-rw-r--r-- | libsolidity/analysis/NameAndTypeResolver.cpp | 4 |
2 files changed, 19 insertions, 7 deletions
diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index f8c12c5b..b33c8568 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -42,20 +42,32 @@ Declaration const* DeclarationContainer::conflictingDeclaration( if (m_invisibleDeclarations.count(*_name)) declarations += m_invisibleDeclarations.at(*_name); - if (dynamic_cast<FunctionDefinition const*>(&_declaration)) + if ( + dynamic_cast<FunctionDefinition const*>(&_declaration) || + dynamic_cast<EventDefinition const*>(&_declaration) + ) { - // check that all other declarations with the same name are functions or a public state variable + // check that all other declarations with the same name are functions or a public state variable or events. + // And then check that the signatures are different. for (Declaration const* declaration: declarations) { - if (dynamic_cast<FunctionDefinition const*>(declaration)) - continue; if (auto variableDeclaration = dynamic_cast<VariableDeclaration const*>(declaration)) { if (variableDeclaration->isStateVariable() && !variableDeclaration->isConstant() && variableDeclaration->isPublic()) continue; return declaration; } - return declaration; + if ( + dynamic_cast<FunctionDefinition const*>(&_declaration) && + !dynamic_cast<FunctionDefinition const*>(declaration) + ) + return declaration; + if ( + dynamic_cast<EventDefinition const*>(&_declaration) && + !dynamic_cast<EventDefinition const*>(declaration) + ) + return declaration; + // Or, continue. } } else if (declarations.size() == 1 && declarations.front() == &_declaration) diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 08323243..b0a82715 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -260,8 +260,8 @@ vector<Declaration const*> NameAndTypeResolver::cleanedDeclarations( for (auto it = _declarations.begin(); it != _declarations.end(); ++it) { solAssert(*it, ""); - // the declaration is functionDefinition or a VariableDeclaration while declarations > 1 - solAssert(dynamic_cast<FunctionDefinition const*>(*it) || dynamic_cast<VariableDeclaration const*>(*it), + // the declaration is functionDefinition, eventDefinition or a VariableDeclaration while declarations > 1 + solAssert(dynamic_cast<FunctionDefinition const*>(*it) || dynamic_cast<EventDefinition const*>(*it) || dynamic_cast<VariableDeclaration const*>(*it), "Found overloading involving something not a function or a variable"); shared_ptr<FunctionType const> functionType { (*it)->functionType(false) }; |