I'm a newbie in Solidity, and I have a question about multiple inheritances.
So if I have some contracts like:
contract A {
function foo() public virtual {
console.log("A");
}
}
contract B is A {
function foo() public virtual override {
console.log("B");
}
}
contract C is A, B {
function foo() public override(A, B) {
super.foo();
}
}
The foo
function of contract C must be override(A, B)
insdead override(B)
or it'd throw an error like Function needs to specify overridden contract "A".
So here's the question, The function must specify the full inheritance parents.
Why can't it know the information by contract C is A, B
,
I mean, what's the point? The overrider(A,B)
part is unnecessary.
Or there are some tricks I don't know?
Please give me an answer, so curious and can't find some useful information by docs.