mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Provide selector for some internal functions.
This commit is contained in:
@@ -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.
|
||||
Reference in New Issue
Block a user