Disallow meta type on super.

This commit is contained in:
chriseth
2020-12-02 15:43:18 +01:00
parent a6158e65c2
commit 52c49aebe8
8 changed files with 11 additions and 30 deletions
@@ -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