Skip to content

Commit 2dc8dbc

Browse files
SQUASH ME: Simplified.
1 parent 3bbd109 commit 2dc8dbc

File tree

5 files changed

+36
-14
lines changed

5 files changed

+36
-14
lines changed

libsolidity/analysis/OverrideChecker.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,17 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
573573
);
574574
}
575575

576-
if (_super.isFunction())
576+
if (_super.isModifier())
577+
{
578+
if (_overriding.unimplemented() && !_super.unimplemented())
579+
overrideError(
580+
_overriding,
581+
_super,
582+
4593_error,
583+
"Overriding an implemented modifier with an unimplemented modifier is not allowed."
584+
);
585+
}
586+
else if (_super.isFunction())
577587
{
578588
FunctionType const* functionType = _overriding.functionType();
579589
FunctionType const* superType = _super.functionType();

libsolidity/analysis/PostTypeChecker.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ void PostTypeChecker::endVisit(ModifierInvocation const& _modifierInvocation)
131131
callEndVisit(_modifierInvocation);
132132
}
133133

134+
bool PostTypeChecker::visit(FunctionDefinition const& _functionDefinition)
135+
{
136+
return callVisit(_functionDefinition);
137+
}
138+
139+
void PostTypeChecker::endVisit(FunctionDefinition const& _functionDefinition)
140+
{
141+
callEndVisit(_functionDefinition);
142+
}
143+
134144
namespace
135145
{
136146
struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker
@@ -434,4 +444,5 @@ PostTypeChecker::PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_err
434444
m_checkers.push_back(make_shared<EventOutsideEmitErrorOutsideRevertChecker>(_errorReporter));
435445
m_checkers.push_back(make_shared<NoVariablesInInterfaceChecker>(_errorReporter));
436446
m_checkers.push_back(make_shared<ReservedErrorSelector>(_errorReporter));
447+
//m_checkers.push_back(make_shared<ModifierImplementedChecker>(_errorReporter));
437448
}

libsolidity/analysis/PostTypeChecker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ class PostTypeChecker: private ASTConstVisitor
9797
bool visit(ModifierInvocation const& _modifierInvocation) override;
9898
void endVisit(ModifierInvocation const& _modifierInvocation) override;
9999

100+
bool visit(FunctionDefinition const& _functionDefinition) override;
101+
void endVisit(FunctionDefinition const& _functionDefinition) override;
102+
100103
template <class T>
101104
bool callVisit(T const& _node)
102105
{

libsolidity/analysis/TypeChecker.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -639,19 +639,6 @@ void TypeChecker::visitManually(
639639
"Can only use modifiers defined in the current contract or in base contracts."
640640
);
641641
}
642-
643-
if (!modifierDecl->isImplemented())
644-
{
645-
SecondarySourceLocation hint;
646-
hint.append("Declared here.", modifierDecl->location());
647-
m_errorReporter.fatalTypeError(
648-
0000_error,
649-
_modifier.location(),
650-
hint,
651-
"Referenced modifier not implemented."
652-
);
653-
}
654-
655642
}
656643
else
657644
// check parameters for Base constructors
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
contract A {
2+
modifier m() virtual { _; }
3+
}
4+
abstract contract B is A {
5+
modifier m() virtual override;
6+
}
7+
contract C is B {
8+
function f() m public {}
9+
}
10+
// ----
11+
// TypeError 4593: (78-108): Overriding an implemented modifier with an unimplemented modifier is not allowed.

0 commit comments

Comments
 (0)