mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow function overloads involving MagicVariableDeclarations.
This commit is contained in:
@@ -45,7 +45,8 @@ Declaration const* DeclarationContainer::conflictingDeclaration(
|
||||
|
||||
if (
|
||||
dynamic_cast<FunctionDefinition const*>(&_declaration) ||
|
||||
dynamic_cast<EventDefinition const*>(&_declaration)
|
||||
dynamic_cast<EventDefinition const*>(&_declaration) ||
|
||||
dynamic_cast<MagicVariableDeclaration const*>(&_declaration)
|
||||
)
|
||||
{
|
||||
// check that all other declarations with the same name are functions or a public state variable or events.
|
||||
@@ -68,6 +69,11 @@ Declaration const* DeclarationContainer::conflictingDeclaration(
|
||||
!dynamic_cast<EventDefinition const*>(declaration)
|
||||
)
|
||||
return declaration;
|
||||
if (
|
||||
dynamic_cast<MagicVariableDeclaration const*>(&_declaration) &&
|
||||
!dynamic_cast<MagicVariableDeclaration const*>(declaration)
|
||||
)
|
||||
return declaration;
|
||||
// Or, continue.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,8 +202,9 @@ vector<Declaration const*> NameAndTypeResolver::cleanedDeclarations(
|
||||
solAssert(
|
||||
dynamic_cast<FunctionDefinition const*>(declaration) ||
|
||||
dynamic_cast<EventDefinition const*>(declaration) ||
|
||||
dynamic_cast<VariableDeclaration const*>(declaration),
|
||||
"Found overloading involving something not a function or a variable."
|
||||
dynamic_cast<VariableDeclaration const*>(declaration) ||
|
||||
dynamic_cast<MagicVariableDeclaration const*>(declaration),
|
||||
"Found overloading involving something not a function, event or a (magic) variable."
|
||||
);
|
||||
|
||||
FunctionTypePointer functionType { declaration->functionType(false) };
|
||||
|
||||
@@ -2124,10 +2124,9 @@ bool TypeChecker::visit(Identifier const& _identifier)
|
||||
|
||||
for (Declaration const* declaration: annotation.overloadedDeclarations)
|
||||
{
|
||||
TypePointer function = declaration->type();
|
||||
solAssert(!!function, "Requested type not present.");
|
||||
auto const* functionType = dynamic_cast<FunctionType const*>(function.get());
|
||||
if (functionType && functionType->canTakeArguments(*annotation.argumentTypes))
|
||||
FunctionTypePointer functionType = declaration->functionType(true);
|
||||
solAssert(!!functionType, "Requested type not present.");
|
||||
if (functionType->canTakeArguments(*annotation.argumentTypes))
|
||||
candidates.push_back(declaration);
|
||||
}
|
||||
if (candidates.empty())
|
||||
|
||||
Reference in New Issue
Block a user