diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 2ef3b03e8..2f98ce4f6 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -954,9 +954,6 @@ Declaration const& Identifier::getReferencedDeclaration() const void Identifier::overloadResolution(TypePointers const& _argumentTypes) { solAssert(!m_referencedDeclaration, "Referenced declaration should be null before overload resolution."); - //to delete - if (m_overloadedDeclarations.empty()) - //---------------------------> solAssert(!m_overloadedDeclarations.empty(), "No candidates for overload resolution found."); vector possibles; diff --git a/libsolidity/AST.h b/libsolidity/AST.h index be118be3d..be5c9a6cd 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -1217,7 +1217,7 @@ public: } Declaration const& getReferencedDeclaration() const; - /// Stores a possible declarations referenced by this identifier. Has to be resolved + /// Stores a set of possible declarations referenced by this identifier. Has to be resolved /// providing argument types using overloadResolution before the referenced declaration /// is accessed. void setOverloadedDeclarations(std::vector const& _declarations) diff --git a/libsolidity/DeclarationContainer.cpp b/libsolidity/DeclarationContainer.cpp index ec8a59bb6..3e23d93b8 100644 --- a/libsolidity/DeclarationContainer.cpp +++ b/libsolidity/DeclarationContainer.cpp @@ -73,7 +73,7 @@ bool DeclarationContainer::registerDeclaration(Declaration const& _declaration, return true; } -std::vector DeclarationContainer::resolveName(ASTString const& _name, bool _recursive) const +std::vector DeclarationContainer::resolveName(ASTString const& _name, bool _recursive) const { solAssert(!_name.empty(), "Attempt to resolve empty name."); auto result = m_declarations.find(_name); diff --git a/libsolidity/NameAndTypeResolver.cpp b/libsolidity/NameAndTypeResolver.cpp index 21b332924..5ef14f60b 100644 --- a/libsolidity/NameAndTypeResolver.cpp +++ b/libsolidity/NameAndTypeResolver.cpp @@ -53,12 +53,12 @@ void NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract) m_currentScope = &m_scopes[&_contract]; linearizeBaseContracts(_contract); - std::vector realBases( + std::vector properBases( ++_contract.getLinearizedBaseContracts().begin(), _contract.getLinearizedBaseContracts().end() ); - for (ContractDefinition const* base: realBases) + for (ContractDefinition const* base: properBases) importInheritedScope(*base); for (ASTPointer const& structDef: _contract.getDefinedStructs()) @@ -130,11 +130,12 @@ vector NameAndTypeResolver::getNameFromCurrentScope(ASTStrin return m_currentScope->resolveName(_name, _recursive); } -vector NameAndTypeResolver::cleanupedDeclarations( +vector NameAndTypeResolver::cleanedDeclarations( Identifier const& _identifier, vector const& _declarations ) { + solAssert(_declarations.size() > 1, ""); vector uniqueFunctions; for (auto it = _declarations.begin(); it != _declarations.end(); ++it) @@ -143,7 +144,7 @@ vector NameAndTypeResolver::cleanupedDeclarations( // the declaration is functionDefinition while declarations > 1 FunctionDefinition const& functionDefinition = dynamic_cast(**it); FunctionType functionType(functionDefinition); - for(auto parameter: functionType.getParameterTypes() + functionType.getReturnParameterTypes()) + for (auto parameter: functionType.getParameterTypes() + functionType.getReturnParameterTypes()) if (!parameter) BOOST_THROW_EXCEPTION( DeclarationError() << @@ -155,9 +156,7 @@ vector NameAndTypeResolver::cleanupedDeclarations( uniqueFunctions.end(), [&](Declaration const* d) { - FunctionDefinition const& newFunctionDefinition = dynamic_cast(*d); - FunctionType newFunctionType(newFunctionDefinition); - + FunctionType newFunctionType(dynamic_cast(*d)); return functionType.hasEqualArgumentTypes(newFunctionType); } )) @@ -482,7 +481,7 @@ bool ReferencesResolver::visit(Identifier& _identifier) else if (declarations.size() == 1) _identifier.setReferencedDeclaration(*declarations.front(), m_currentContract); else - _identifier.setOverloadedDeclarations(m_resolver.cleanupedDeclarations(_identifier, declarations)); + _identifier.setOverloadedDeclarations(m_resolver.cleanedDeclarations(_identifier, declarations)); return false; } diff --git a/libsolidity/NameAndTypeResolver.h b/libsolidity/NameAndTypeResolver.h index 7855217a2..d7a0a3b2f 100644 --- a/libsolidity/NameAndTypeResolver.h +++ b/libsolidity/NameAndTypeResolver.h @@ -56,13 +56,17 @@ public: /// Resolves the given @a _name inside the scope @a _scope. If @a _scope is omitted, /// the global scope is used (i.e. the one containing only the contract). /// @returns a pointer to the declaration on success or nullptr on failure. - std::vector resolveName(ASTString const& _name, Declaration const* _scope = nullptr) const; + std::vector resolveName(ASTString const& _name, Declaration const* _scope = nullptr) const; /// Resolves a name in the "current" scope. Should only be called during the initial /// resolving phase. std::vector getNameFromCurrentScope(ASTString const& _name, bool _recursive = true); - std::vector cleanupedDeclarations(Identifier const& _identifier, std::vector const& _declarations); + /// returns the vector of declarations without repetitions + static std::vector cleanedDeclarations( + Identifier const& _identifier, + std::vector const& _declarations + ); private: void reset(); diff --git a/libsolidity/Types.h b/libsolidity/Types.h index 5b95e5567..da2fcdb89 100644 --- a/libsolidity/Types.h +++ b/libsolidity/Types.h @@ -617,7 +617,7 @@ public: /// @returns true if this function can take the given argument types (possibly /// after implicit conversion). bool canTakeArguments(TypePointers const& _arguments) const; - /// @returns true if the types of parameters are equal(does't check return parameter types) + /// @returns true if the types of parameters are equal (does't check return parameter types) bool hasEqualArgumentTypes(FunctionType const& _other) const; Location const& getLocation() const { return m_location; }