For example, we have a contract:
contract A {
modifier checkCaller() {
require(msg.sender == 0x123);
_;
}
function doSmth() checkCaller {}
}
We make child contract and override function:
contract B is A {
function doSmth() {
super.doSmth();
// ... do more
}
}
Do I need to explicitly use modifier checkCaller
in the child contract B
? As I understand super.doSmth()
will throw properly. Correct?
Best Answer
Yes, you are correct.
Something I noticed which is worth keeping an eye on is that both modifiers of 'parent' contracts as well as any functions are overwritten by inheritance even when using 'super'.
For example, calling
test(0)
on B passes and returns 10 (not 5 as one may be led to believe), but fails on contract A.