Provide selector for some internal functions.

This commit is contained in:
chriseth
2021-03-01 16:19:59 +01:00
parent 44493ad428
commit 5e94fce7df
5 changed files with 72 additions and 1 deletions
@@ -0,0 +1,11 @@
contract B {
function g() public {}
}
contract C is B {
bytes4 constant s2 = B.g.selector;
function f() external pure returns (bytes4) { return s2; }
}
// ====
// compileViaYul: also
// ----
// f() -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,14 @@
contract B {
function ext() external {}
function pub() public {}
}
contract C is B {
function test() public returns (bytes4, bytes4, bytes4, bytes4) {
return (B.ext.selector, B.pub.selector, this.ext.selector, pub.selector);
}
}
// ====
// compileViaYul: true
// ----
// test() -> 0xcf9f23b500000000000000000000000000000000000000000000000000000000, 0x7defb41000000000000000000000000000000000000000000000000000000000, 0xcf9f23b500000000000000000000000000000000000000000000000000000000, 0x7defb41000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,14 @@
contract B {
function ext() external {}
function pub() public {}
}
contract D {
function test() public returns (bytes4, bytes4) {
return (B.ext.selector, B.pub.selector);
}
}
// ====
// compileViaYul: true
// ----
// test() -> 0xcf9f23b500000000000000000000000000000000000000000000000000000000, 0x7defb41000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,26 @@
contract B {
function ext() external {}
function pub() public {}
}
contract C is B {
function test() public pure {
B.ext.selector;
B.pub.selector;
this.ext.selector;
pub.selector;
}
}
contract D {
function test() public pure {
B.ext.selector;
B.pub.selector;
}
}
// ----
// Warning 6133: (136-150): Statement has no effect.
// Warning 6133: (160-174): Statement has no effect.
// Warning 6133: (184-201): Statement has no effect.
// Warning 6133: (289-303): Statement has no effect.
// Warning 6133: (313-327): Statement has no effect.