mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix checks for "using for ... global" for libraries.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using L for I;
|
||||
interface I { function f() external pure returns (uint); }
|
||||
library L {
|
||||
function execute(I i) internal pure returns (uint) {
|
||||
return i.f();
|
||||
}
|
||||
}
|
||||
contract C is I {
|
||||
function x() public view returns (uint) {
|
||||
I i = this;
|
||||
return i.execute();
|
||||
}
|
||||
function f() public pure returns (uint) { return 7; }
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// x() -> 7
|
||||
@@ -0,0 +1,38 @@
|
||||
==== Source: A ====
|
||||
enum E {A, B}
|
||||
struct S { uint x; }
|
||||
type T is uint;
|
||||
using L for E global;
|
||||
using L for S global;
|
||||
using L for T global;
|
||||
library L {
|
||||
function f(E e) internal pure returns (uint) {
|
||||
return uint(e);
|
||||
}
|
||||
function f(S memory s) internal pure returns (uint) {
|
||||
return s.x;
|
||||
}
|
||||
function f(T t) internal pure returns (uint) {
|
||||
return T.unwrap(t);
|
||||
}
|
||||
}
|
||||
|
||||
==== Source: B ====
|
||||
contract C {
|
||||
function f() public pure returns (uint a, uint b, uint c) {
|
||||
E e = E.B;
|
||||
a = e.f();
|
||||
S memory s;
|
||||
s.x = 7;
|
||||
b = s.f();
|
||||
T t = T.wrap(9);
|
||||
c = t.f();
|
||||
}
|
||||
}
|
||||
|
||||
import {E, S, T} from "A";
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 1, 7, 9
|
||||
Reference in New Issue
Block a user