mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Implement `super`.
This commit is contained in:
@@ -30,6 +30,7 @@ contract D is B, C {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 15
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
contract A {
|
||||
function f() public virtual returns (uint256 r) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract B is A {
|
||||
function f() public virtual override returns (uint256 r) {
|
||||
function() internal returns (uint) x = super.f;
|
||||
return x() | 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract C is A {
|
||||
function f() public virtual override returns (uint256 r) {
|
||||
function() internal returns (uint) x = super.f;
|
||||
return x() | 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract D is B, C {
|
||||
uint256 data;
|
||||
|
||||
constructor() {
|
||||
function() internal returns (uint) x = super.f;
|
||||
data = x() | 8;
|
||||
}
|
||||
|
||||
function f() public override (B, C) returns (uint256 r) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 15
|
||||
@@ -22,6 +22,8 @@ contract C is A, B {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g() -> 10
|
||||
// h() -> 2
|
||||
|
||||
@@ -25,5 +25,7 @@ contract D is B, C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 15
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
contract A {
|
||||
function f() public virtual returns (uint256 r) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract B is A {
|
||||
function f() public virtual override returns (uint256 r) {
|
||||
return ((super).f)() | 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract C is A {
|
||||
function f() public virtual override returns (uint256 r) {
|
||||
return ((super).f)() | 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract D is B, C {
|
||||
function f() public override(B, C) returns (uint256 r) {
|
||||
return ((super).f)() | 8;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 15
|
||||
Reference in New Issue
Block a user