From 846f7dc3ea6591b34deb3e6738292ffd87c06ed3 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Thu, 20 Oct 2016 10:47:15 +0200 Subject: analysis: Resolve event overloading --- libsolidity/analysis/DeclarationContainer.cpp | 21 +++++++++------------ libsolidity/analysis/NameAndTypeResolver.cpp | 4 ++-- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index ac80ab18..04836603 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -42,28 +42,25 @@ Declaration const* DeclarationContainer::conflictingDeclaration( if (m_invisibleDeclarations.count(*_name)) declarations += m_invisibleDeclarations.at(*_name); - if (dynamic_cast(&_declaration)) + if (dynamic_cast(&_declaration) || + dynamic_cast(&_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(declaration)) - continue; if (auto variableDeclaration = dynamic_cast(declaration)) { if (variableDeclaration->isStateVariable() && !variableDeclaration->isConstant() && variableDeclaration->isPublic()) continue; return declaration; } - return declaration; - } - } - else if (dynamic_cast(&_declaration)) - { - // check that all other declarations with the same name are events - for (Declaration const* declaration: declarations) - if (!dynamic_cast(declaration)) + if (!dynamic_cast(declaration) && + !dynamic_cast(declaration)) return declaration; + // Or, continue. + } } else if (declarations.size() == 1 && declarations.front() == &_declaration) return nullptr; 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 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(*it) || dynamic_cast(*it), + // the declaration is functionDefinition, eventDefinition or a VariableDeclaration while declarations > 1 + solAssert(dynamic_cast(*it) || dynamic_cast(*it) || dynamic_cast(*it), "Found overloading involving something not a function or a variable"); shared_ptr functionType { (*it)->functionType(false) }; -- cgit