-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalling_parent_function.sol
53 lines (44 loc) · 1.09 KB
/
calling_parent_function.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract E {
// This event will be used to trace function calls.
event Log(string message);
function foo() public virtual {
emit Log("E.foo");
}
function bar() public virtual {
emit Log("E.bar");
}
}
contract F is E {
function foo() public virtual override {
emit Log("F.foo");
E.foo();
}
function bar() public virtual override {
emit Log("F.bar");
super.bar();
}
}
contract G is E {
function foo() public virtual override {
emit Log("G.foo");
E.foo();
}
function bar() public virtual override {
emit Log("G.bar");
super.bar();
}
}
contract H is F, G {
function foo() public override(F, G) {
// Calls G.foo() and then E.foo()
// Inside F and G, E.foo() is called. Solidity is smart enough
// to not call E.foo() twice. Hence E.foo() is only called by G.foo().
super.foo();
}
function bar() public override(F, G) {
// Write your code here
super.bar();
}
}