diff options
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 39 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.h | 1 | ||||
-rw-r--r-- | libsolidity/interface/ErrorReporter.h | 4 |
3 files changed, 18 insertions, 26 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index df791be9..2a9ca5a8 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -306,40 +306,31 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, Func return; if (function.visibility() != super.visibility()) - m_errorReporter.typeError( - function.location(), - "Overriding function visibility differs from " + super.fullyQualifiedName() + "." - ); + overrideError(function, super, "Overriding function visibility differs."); if (function.isDeclaredConst() && !super.isDeclaredConst()) - m_errorReporter.typeError( - function.location(), - "Overriding function should not be declared constant." - ); + overrideError(function, super, "Overriding function should not be declared constant."); if (!function.isDeclaredConst() && super.isDeclaredConst()) - m_errorReporter.typeError( - function.location(), - "Overriding function should be declared constant." - ); + overrideError(function, super, "Overriding function should be declared constant."); if (function.isPayable() && !super.isPayable()) - m_errorReporter.typeError( - function.location(), - "Overriding function should not be declared payable." - ); + overrideError(function, super, "Overriding function should not be declared payable."); if (!function.isPayable() && super.isPayable()) - m_errorReporter.typeError( - function.location(), - "Overriding function should be declared payable." - ); + overrideError(function, super, "Overriding function should be declared payable."); if (functionType != superType) - m_errorReporter.typeError( - function.location(), - "Overriding function return types differ from " + super.fullyQualifiedName() + "." - ); + overrideError(function, super, "Overriding function return types differ."); +} + +void TypeChecker::overrideError(FunctionDefinition const& function, FunctionDefinition const& super, string message) +{ + m_errorReporter.typeError( + function.location(), + SecondarySourceLocation().append("Overriden function is here:", super.location()), + message + ); } void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _contract) diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index f1004e92..f2e13765 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -64,6 +64,7 @@ private: void checkContractIllegalOverrides(ContractDefinition const& _contract); /// Reports a type error with an appropiate message if overriden function signature differs. void checkFunctionOverride(FunctionDefinition const& function, FunctionDefinition const& super); + void overrideError(FunctionDefinition const& function, FunctionDefinition const& super, std::string message); void checkContractAbstractFunctions(ContractDefinition const& _contract); void checkContractAbstractConstructors(ContractDefinition const& _contract); /// Checks that different functions with external visibility end up having different diff --git a/libsolidity/interface/ErrorReporter.h b/libsolidity/interface/ErrorReporter.h index 42b0c8b6..12f4e8df 100644 --- a/libsolidity/interface/ErrorReporter.h +++ b/libsolidity/interface/ErrorReporter.h @@ -75,8 +75,8 @@ public: void typeError( SourceLocation const& _location, - SecondarySourceLocation const& _secondaryLocation, - std::string const& _description + SecondarySourceLocation const& _secondaryLocation = SecondarySourceLocation(), + std::string const& _description = std::string() ); void typeError(SourceLocation const& _location, std::string const& _description); |