aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-10-20 16:47:15 +0800
committerYoichi Hirai <i@yoichihirai.com>2017-01-23 22:25:13 +0800
commit846f7dc3ea6591b34deb3e6738292ffd87c06ed3 (patch)
tree245f7f785976205bc4f562791ac04e386a2be989 /libsolidity/analysis
parent4c09e81c3e60ddc43709656f9be4f991360b4108 (diff)
downloaddexon-solidity-846f7dc3ea6591b34deb3e6738292ffd87c06ed3.tar.gz
dexon-solidity-846f7dc3ea6591b34deb3e6738292ffd87c06ed3.tar.zst
dexon-solidity-846f7dc3ea6591b34deb3e6738292ffd87c06ed3.zip
analysis: Resolve event overloading
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/DeclarationContainer.cpp21
-rw-r--r--libsolidity/analysis/NameAndTypeResolver.cpp4
2 files changed, 11 insertions, 14 deletions
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<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;
- }
- }
- else if (dynamic_cast<EventDefinition const*>(&_declaration))
- {
- // check that all other declarations with the same name are events
- for (Declaration const* declaration: declarations)
- if (!dynamic_cast<EventDefinition const*>(declaration))
+ if (!dynamic_cast<FunctionDefinition const*>(declaration) &&
+ !dynamic_cast<EventDefinition const*>(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<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) };