From cf00faca330cc29db1d67b06c5117ae3cb6b518d Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 10 Jun 2021 14:38:45 +0200 Subject: [PATCH] Properly use AST node name also for secondary location. --- libsolidity/analysis/OverrideChecker.cpp | 24 +++++++++++------------- libsolidity/analysis/OverrideChecker.h | 9 +-------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/libsolidity/analysis/OverrideChecker.cpp b/libsolidity/analysis/OverrideChecker.cpp index 6ec18520d..18a40be40 100644 --- a/libsolidity/analysis/OverrideChecker.cpp +++ b/libsolidity/analysis/OverrideChecker.cpp @@ -661,23 +661,21 @@ void OverrideChecker::overrideListError( ); } -void OverrideChecker::overrideError(Declaration const& _overriding, Declaration const& _super, ErrorId _error, string const& _message, string const& _secondaryMsg) +void OverrideChecker::overrideError( + OverrideProxy const& _overriding, + OverrideProxy const& _super, + ErrorId _error, + string const& _message, + optional const& _secondaryMsg +) { m_errorReporter.typeError( _error, _overriding.location(), - SecondarySourceLocation().append(_secondaryMsg, _super.location()), - _message - ); -} - - -void OverrideChecker::overrideError(OverrideProxy const& _overriding, OverrideProxy const& _super, ErrorId _error, string const& _message, string const& _secondaryMsg) -{ - m_errorReporter.typeError( - _error, - _overriding.location(), - SecondarySourceLocation().append(_secondaryMsg, _super.location()), + SecondarySourceLocation().append( + _secondaryMsg.value_or("Overridden " + _super.astNodeName() + " is here:"), + _super.location() + ), _message ); } diff --git a/libsolidity/analysis/OverrideChecker.h b/libsolidity/analysis/OverrideChecker.h index 564100453..9178d179d 100644 --- a/libsolidity/analysis/OverrideChecker.h +++ b/libsolidity/analysis/OverrideChecker.h @@ -166,19 +166,12 @@ private: std::string const& _message1, std::string const& _message2 ); - void overrideError( - Declaration const& _overriding, - Declaration const& _super, - langutil::ErrorId _error, - std::string const& _message, - std::string const& _secondaryMsg = "Overridden function is here:" - ); void overrideError( OverrideProxy const& _overriding, OverrideProxy const& _super, langutil::ErrorId _error, std::string const& _message, - std::string const& _secondaryMsg = "Overridden function is here:" + std::optional const& _secondaryMsg = {} ); /// Checks for functions in different base contracts which conflict with each /// other and thus need to be overridden explicitly.