Legacy codegeneration for immutable state variables.

This commit is contained in:
Daniel Kirchner
2020-03-24 16:45:25 +01:00
committed by chriseth
parent 83cbfbb7bf
commit 04d8ad2ae1
22 changed files with 471 additions and 17 deletions
@@ -0,0 +1,20 @@
contract D {
function f() external view returns (uint256) {
return 42;
}
}
contract C {
D d;
function() external view returns(uint256) immutable z;
constructor() public {
d = new D();
z = d.f;
}
function f() public view returns (uint256) {
assert(z.address == address(d));
assert(z.selector == D.f.selector);
return z();
}
}
// ----
// f() -> 42
@@ -0,0 +1,13 @@
contract C {
uint256 immutable x;
uint256 immutable y;
constructor() public {
x = 42;
y = x;
}
function f() public view returns (uint256, uint256) {
return (x+x,y);
}
}
// ----
// f() -> 84, 42
@@ -0,0 +1,13 @@
contract C {
uint256 immutable x;
uint256 immutable y;
constructor() public {
x = 42;
y = 23;
}
function f() public view returns (uint256, uint256) {
return (x+x,y);
}
}
// ----
// f() -> 84, 23