diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-08-04 04:47:13 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-08-05 01:06:23 +0800 |
commit | 32acadf43d655413e65428475a35e7ef3bf8fb78 (patch) | |
tree | bafef82f60ee9630592e7e67540bd67b5da59d83 /libsolidity | |
parent | dc0f85c4fb65fa385bb7145c73cc5edaba195483 (diff) | |
download | dexon-solidity-32acadf43d655413e65428475a35e7ef3bf8fb78.tar.gz dexon-solidity-32acadf43d655413e65428475a35e7ef3bf8fb78.tar.zst dexon-solidity-32acadf43d655413e65428475a35e7ef3bf8fb78.zip |
Do not mark overloaded functions as shadowing
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/NameAndTypeResolver.cpp | 19 | ||||
-rw-r--r-- | libsolidity/analysis/NameAndTypeResolver.h | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index df83f382..83de2b3e 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -439,6 +439,23 @@ DeclarationRegistrationHelper::DeclarationRegistrationHelper( solAssert(m_currentScope == _currentScope, "Scopes not correctly closed."); } +bool DeclarationRegistrationHelper::isOverloadedFunction( + Declaration const& _declaration1, + Declaration const& _declaration2 +) +{ + auto const* function1 = dynamic_cast<FunctionDefinition const*>(&_declaration1); + auto const* function2 = dynamic_cast<FunctionDefinition const*>(&_declaration2); + + if (!function1 || !function2) + return false; + + if (function1->parameters() != function2->parameters()) + return true; + + return false; +} + bool DeclarationRegistrationHelper::registerDeclaration( DeclarationContainer& _container, Declaration const& _declaration, @@ -454,7 +471,7 @@ bool DeclarationRegistrationHelper::registerDeclaration( Declaration const* shadowedDeclaration = nullptr; if (_warnOnShadow && !_declaration.name().empty()) for (auto const* decl: _container.resolveName(_declaration.name(), true)) - if (decl != &_declaration) + if (decl != &_declaration && !isOverloadedFunction(*decl, _declaration)) { shadowedDeclaration = decl; break; diff --git a/libsolidity/analysis/NameAndTypeResolver.h b/libsolidity/analysis/NameAndTypeResolver.h index a498c7ba..59bd3b1f 100644 --- a/libsolidity/analysis/NameAndTypeResolver.h +++ b/libsolidity/analysis/NameAndTypeResolver.h @@ -169,6 +169,8 @@ private: void closeCurrentScope(); void registerDeclaration(Declaration& _declaration, bool _opensScope); + static bool isOverloadedFunction(Declaration const& _declaration1, Declaration const& _declaration2); + /// @returns the canonical name of the current scope. std::string currentCanonicalName() const; |