solidity/test/libsolidity/semanticTests/viaYul/virtual_functions.sol

34 lines
650 B
Solidity
Raw Normal View History

2019-04-02 10:37:48 +00:00
contract X {
function f() public returns (uint x) {
x = g();
}
2019-11-05 17:25:34 +00:00
function g() public virtual returns (uint x) {
2019-04-02 10:37:48 +00:00
x = 2;
}
}
contract C is X {
function f1() public returns (uint x) {
// direct call
x = g();
}
function f2() public returns (uint x) {
// call via base
x = f();
}
function f3() public returns (uint x) {
// explicit call via base
//x = super.g();
}
2019-09-16 12:33:43 +00:00
function g() public override returns (uint x) {
2019-04-02 10:37:48 +00:00
x = 3;
}
}
2019-05-08 08:46:38 +00:00
// ====
// compileViaYul: also
// compileToEwasm: also
2019-04-02 10:37:48 +00:00
// ----
// f() -> 3
// f1() -> 3
// f2() -> 3
// g() -> 3