2021-11-16 16:01:09 +00:00
|
|
|
==== Source: A ====
|
|
|
|
type T is uint;
|
|
|
|
using L for T global;
|
|
|
|
library L {
|
|
|
|
function inc(T x) internal pure returns (T) {
|
|
|
|
return T.wrap(T.unwrap(x) + 1);
|
|
|
|
}
|
|
|
|
function dec(T x) external pure returns (T) {
|
|
|
|
return T.wrap(T.unwrap(x) - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
using {unwrap} for T global;
|
|
|
|
function unwrap(T x) pure returns (uint) {
|
|
|
|
return T.unwrap(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
==== Source: B ====
|
|
|
|
contract C {
|
|
|
|
function f() public pure returns (T r1) {
|
|
|
|
r1 = r1.inc().inc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
import {T} from "A";
|
|
|
|
|
|
|
|
==== Source: C ====
|
|
|
|
import {C} from "B";
|
|
|
|
|
|
|
|
contract D {
|
|
|
|
function test() public returns (uint) {
|
|
|
|
C c = new C();
|
2022-08-30 09:53:02 +00:00
|
|
|
// This tests that attached functions are available
|
2021-11-16 16:01:09 +00:00
|
|
|
// even if the type is not available by name.
|
|
|
|
// This is a regular function call, a
|
|
|
|
// public and an internal library call
|
|
|
|
// and a free function call.
|
|
|
|
return c.f().inc().inc().dec().unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ----
|
|
|
|
// library: "A":L
|
|
|
|
// test() -> 3
|
2023-05-09 16:22:44 +00:00
|
|
|
// gas legacy: 120881
|