What if I want to have
ERC20Checkpoint
andERC20Votes
extensions simultaneously.
Yeah, not sure about this. I wouldn't feel comfortable mixing them up. Generally, I'd prefer to keep each contract with a single responsibility. Though I recognize it may depend on the use case.
Then in MyToken which inherits from ERC20Votes and ERC20Checkpoints I will need to write such an override
I'd suggest studying how Solidity supports multiple inheritance and polymorfism. If two contracts implement the same function, their execution order will be defined by a linearization algorithm.
In the current override you're adding, you'll be calling ERC20's _update
function twice.
My advice is to use a super._update()
instead, it will call the functions one level higher up in the flattened inheritance hierarchy.
I'd suggest looking at your different _update()
functions and see if there's a reason why order execution should matter. In case there's a reason, you should select the execution order by changing the inheritance order.
Some examples:
// _updates()'s are executed in the following order:
// 1 - Base1
// 2 - Base2
// 3 - Derived1
contract Derived1 is Base1, Base2 {
_update() { super._update() }
}
// _update()'s are executed in the following order:
// 1 - Base2
// 2 - Base1
// 3 - Derived2
contract Derived2 is Base2, Base1 {
_update() { super._update() }
}