mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
analysis: Resolve event overloading
This commit is contained in:
parent
4c09e81c3e
commit
846f7dc3ea
@ -42,28 +42,25 @@ Declaration const* DeclarationContainer::conflictingDeclaration(
|
|||||||
if (m_invisibleDeclarations.count(*_name))
|
if (m_invisibleDeclarations.count(*_name))
|
||||||
declarations += m_invisibleDeclarations.at(*_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)
|
for (Declaration const* declaration: declarations)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<FunctionDefinition const*>(declaration))
|
|
||||||
continue;
|
|
||||||
if (auto variableDeclaration = dynamic_cast<VariableDeclaration const*>(declaration))
|
if (auto variableDeclaration = dynamic_cast<VariableDeclaration const*>(declaration))
|
||||||
{
|
{
|
||||||
if (variableDeclaration->isStateVariable() && !variableDeclaration->isConstant() && variableDeclaration->isPublic())
|
if (variableDeclaration->isStateVariable() && !variableDeclaration->isConstant() && variableDeclaration->isPublic())
|
||||||
continue;
|
continue;
|
||||||
return declaration;
|
return declaration;
|
||||||
}
|
}
|
||||||
return declaration;
|
if (!dynamic_cast<FunctionDefinition const*>(declaration) &&
|
||||||
}
|
!dynamic_cast<EventDefinition const*>(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))
|
|
||||||
return declaration;
|
return declaration;
|
||||||
|
// Or, continue.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (declarations.size() == 1 && declarations.front() == &_declaration)
|
else if (declarations.size() == 1 && declarations.front() == &_declaration)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -260,8 +260,8 @@ vector<Declaration const*> NameAndTypeResolver::cleanedDeclarations(
|
|||||||
for (auto it = _declarations.begin(); it != _declarations.end(); ++it)
|
for (auto it = _declarations.begin(); it != _declarations.end(); ++it)
|
||||||
{
|
{
|
||||||
solAssert(*it, "");
|
solAssert(*it, "");
|
||||||
// the declaration is functionDefinition or a VariableDeclaration while declarations > 1
|
// the declaration is functionDefinition, eventDefinition or a VariableDeclaration while declarations > 1
|
||||||
solAssert(dynamic_cast<FunctionDefinition const*>(*it) || dynamic_cast<VariableDeclaration const*>(*it),
|
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");
|
"Found overloading involving something not a function or a variable");
|
||||||
|
|
||||||
shared_ptr<FunctionType const> functionType { (*it)->functionType(false) };
|
shared_ptr<FunctionType const> functionType { (*it)->functionType(false) };
|
||||||
|
Loading…
Reference in New Issue
Block a user