Revert the change that made events accessible in other contacts via qualified access

This commit is contained in:
Kamil Śliwak 2022-06-14 10:17:23 +02:00
parent 82e5339d23
commit acbdcc3711
8 changed files with 44 additions and 25 deletions

View File

@ -6,7 +6,6 @@ Important Bugfixes:
Language Features:
* Add `E.selector` for a non-anonymous event `E` to access the 32-byte selector topic.
* Errors and Events allow qualified access from other contracts.
Compiler Features:

View File

@ -1216,7 +1216,7 @@ public:
FunctionTypePointer functionType(bool /*_internal*/) const override;
bool isVisibleInDerivedContracts() const override { return true; }
bool isVisibleViaContractTypeAccess() const override { return true; }
bool isVisibleViaContractTypeAccess() const override { return false; /* TODO */ }
EventDefinitionAnnotation& annotation() const override;

View File

@ -7,32 +7,26 @@ library S {
library T {
event E();
}
interface I {
event E();
}
contract D {
event F();
}
contract C is D {
function test1() external pure returns (bytes32, bytes32, bytes32) {
function test1() external pure returns (bytes32, bytes32) {
assert(L.E.selector == T.E.selector);
assert(I.E.selector == L.E.selector);
assert(L.E.selector != S.E.selector);
assert(T.E.selector != S.E.selector);
assert(I.E.selector != S.E.selector);
return (L.E.selector, S.E.selector, I.E.selector);
return (L.E.selector, S.E.selector);
}
bytes32 s1 = L.E.selector;
bytes32 s2 = S.E.selector;
bytes32 s3 = T.E.selector;
bytes32 s4 = I.E.selector;
function test2() external returns (bytes32, bytes32, bytes32, bytes32) {
return (s1, s2, s3, s4);
function test2() external returns (bytes32, bytes32, bytes32) {
return (s1, s2, s3);
}
function test3() external returns (bytes32) {
@ -42,6 +36,6 @@ contract C is D {
// ====
// compileViaYul: also
// ----
// test1() -> 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x2ff0672f372fbe844b353429d4510ea5e43683af134c54f75f789ff57bc0c0, 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028
// test2() -> 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x2ff0672f372fbe844b353429d4510ea5e43683af134c54f75f789ff57bc0c0, 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028
// test1() -> 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x2ff0672f372fbe844b353429d4510ea5e43683af134c54f75f789ff57bc0c0
// test2() -> 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028, 0x2ff0672f372fbe844b353429d4510ea5e43683af134c54f75f789ff57bc0c0, 0x92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028
// test3() -> 0x28811f5935c16a099486acb976b3a6b4942950a1425a74e9eb3e9b7f7135e12a

View File

@ -2,7 +2,7 @@ contract C {
event E();
}
contract Test {
contract Test is C {
event E(uint256, uint256);
function f() public {
emit C.E();

View File

@ -0,0 +1,11 @@
contract D {
event E();
}
contract C {
function f() external pure returns (bytes32) {
return D.E.selector;
}
}
// ----
// TypeError 9582: (110-113): Member "E" not found or not visible after argument-dependent lookup in type(contract D).

View File

@ -0,0 +1,11 @@
interface I {
event E();
}
contract C {
function f() external pure returns (bytes32) {
return I.E.selector;
}
}
// ----
// TypeError 9582: (111-114): Member "E" not found or not visible after argument-dependent lookup in type(contract I).

View File

@ -0,0 +1,10 @@
library L {
event E();
}
contract C {
function f() external pure returns (bytes32) {
return L.E.selector;
}
}
// ----

View File

@ -7,33 +7,27 @@ library S {
library T {
event E();
}
interface I {
event E();
}
contract D {
event F();
}
contract C is D {
function test1() external pure returns (bytes32, bytes32, bytes32) {
function test1() external pure returns (bytes32, bytes32) {
assert(L.E.selector == T.E.selector);
assert(I.E.selector == L.E.selector);
assert(L.E.selector != S.E.selector);
assert(T.E.selector != S.E.selector);
assert(I.E.selector != S.E.selector);
return (L.E.selector, S.E.selector, I.E.selector);
return (L.E.selector, S.E.selector);
}
bytes32 s1 = L.E.selector;
bytes32 s2 = S.E.selector;
bytes32 s3 = T.E.selector;
bytes32 s4 = I.E.selector;
function test2() view external returns (bytes32, bytes32, bytes32, bytes32) {
return (s1, s2, s3, s4);
function test2() view external returns (bytes32, bytes32, bytes32) {
return (s1, s2, s3);
}
function test3() pure external returns (bytes32) {