2020-03-12 16:32:10 +00:00
|
|
|
contract A {
|
|
|
|
uint immutable a;
|
2020-06-23 12:14:24 +00:00
|
|
|
constructor() {
|
2020-03-12 16:32:10 +00:00
|
|
|
a = 7;
|
|
|
|
}
|
|
|
|
function f() public view returns (uint) { return a; }
|
|
|
|
}
|
|
|
|
contract B {
|
|
|
|
uint immutable a;
|
2020-06-23 12:14:24 +00:00
|
|
|
constructor() {
|
2020-03-12 16:32:10 +00:00
|
|
|
a = 5;
|
|
|
|
}
|
|
|
|
function f() public view returns (uint) { return a; }
|
|
|
|
}
|
|
|
|
contract C {
|
|
|
|
uint immutable a;
|
|
|
|
uint public x;
|
|
|
|
uint public y;
|
2020-06-23 12:14:24 +00:00
|
|
|
constructor() {
|
2020-03-12 16:32:10 +00:00
|
|
|
a = 3;
|
|
|
|
x = (new A()).f();
|
|
|
|
y = (new B()).f();
|
|
|
|
}
|
|
|
|
function f() public returns (uint256, uint, uint) {
|
|
|
|
return (a, (new A()).f(), (new B()).f());
|
|
|
|
}
|
|
|
|
}
|
2020-04-17 20:24:33 +00:00
|
|
|
// ====
|
|
|
|
// compileViaYul: also
|
2020-03-12 16:32:10 +00:00
|
|
|
// ----
|
|
|
|
// f() -> 3, 7, 5
|
2021-07-01 12:17:27 +00:00
|
|
|
// gas irOptimized: 127613
|
2021-05-18 13:39:08 +00:00
|
|
|
// gas legacy: 151590
|
|
|
|
// gas legacyOptimized: 125422
|
2020-03-12 16:32:10 +00:00
|
|
|
// x() -> 7
|
|
|
|
// y() -> 5
|