mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow meta type on super.
This commit is contained in:
@@ -21,13 +21,9 @@ contract Test is C {
|
||||
function i() public pure returns (string memory) {
|
||||
return type(I).name;
|
||||
}
|
||||
function j() public pure returns (string memory) {
|
||||
return type(super).name;
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// c() -> 0x20, 1, "C"
|
||||
// a() -> 0x20, 1, "A"
|
||||
// i() -> 0x20, 1, "I"
|
||||
// j() -> 0x20, 1, "C"
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
function compareStrings(string memory s1, string memory s2) returns (bool) {
|
||||
return keccak256(abi.encodePacked(s1)) == keccak256(abi.encodePacked(s2));
|
||||
}
|
||||
|
||||
contract A {
|
||||
string[] r;
|
||||
function f() public virtual returns (bool) {
|
||||
r.push("");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract B is A {
|
||||
function f() public virtual override returns (bool) {
|
||||
super.f();
|
||||
r.push(type(super).name);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract C is A {
|
||||
function f() public virtual override returns (bool) {
|
||||
super.f();
|
||||
r.push(type(super).name);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract D is B, C {
|
||||
function f() public override(B, C) returns (bool) {
|
||||
super.f();
|
||||
r.push(type(super).name);
|
||||
// Order of calls: D.f, C.f, B.f, A.f
|
||||
// r contains "", "A", "B", "C"
|
||||
assert(r.length == 4);
|
||||
assert(compareStrings(r[0], ""));
|
||||
assert(compareStrings(r[1], "A"));
|
||||
assert(compareStrings(r[2], "B"));
|
||||
assert(compareStrings(r[3], "C"));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// f() -> true
|
||||
Reference in New Issue
Block a user