diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index e5fcf8d8c..344610769 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -145,11 +145,7 @@ void DeclarationTypeChecker::endVisit(UserDefinedTypeName const& _typeName) else if (EnumDefinition const* enumDef = dynamic_cast(declaration)) _typeName.annotation().type = TypeProvider::enumType(*enumDef); else if (ContractDefinition const* contract = dynamic_cast(declaration)) - { - if (contract->isLibrary()) - m_errorReporter.typeError(1130_error, _typeName.location(), "Invalid use of a library name."); _typeName.annotation().type = TypeProvider::contract(*contract); - } else { _typeName.annotation().type = TypeProvider::emptyTuple(); @@ -161,6 +157,16 @@ void DeclarationTypeChecker::endVisit(UserDefinedTypeName const& _typeName) } } +void DeclarationTypeChecker::endVisit(IdentifierPath const& _path) +{ + Declaration const* declaration = _path.annotation().referencedDeclaration; + solAssert(declaration, ""); + + if (ContractDefinition const* contract = dynamic_cast(declaration)) + if (contract->isLibrary()) + m_errorReporter.typeError(1130_error, _path.location(), "Invalid use of a library name."); +} + bool DeclarationTypeChecker::visit(FunctionTypeName const& _typeName) { if (_typeName.annotation().type) @@ -402,7 +408,6 @@ bool DeclarationTypeChecker::visit(UsingForDirective const& _usingFor) if (!library || !library->isLibrary()) m_errorReporter.fatalTypeError(4357_error, _usingFor.libraryName().location(), "Library name expected."); - _usingFor.libraryName().annotation().type = TypeProvider::contract(*library); if (_usingFor.typeName()) _usingFor.typeName()->accept(*this); diff --git a/libsolidity/analysis/DeclarationTypeChecker.h b/libsolidity/analysis/DeclarationTypeChecker.h index 037ba1dee..42ea149e9 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.h +++ b/libsolidity/analysis/DeclarationTypeChecker.h @@ -54,6 +54,7 @@ private: bool visit(ElementaryTypeName const& _typeName) override; void endVisit(UserDefinedTypeName const& _typeName) override; + void endVisit(IdentifierPath const& _identifierPath) override; bool visit(FunctionTypeName const& _typeName) override; void endVisit(Mapping const& _mapping) override; void endVisit(ArrayTypeName const& _typeName) override;