mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			603 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			603 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
contract A {
 | 
						|
	uint immutable a;
 | 
						|
	constructor() {
 | 
						|
		a = 7;
 | 
						|
	}
 | 
						|
	function f() public view returns (uint) { return a; }
 | 
						|
}
 | 
						|
contract B {
 | 
						|
	uint immutable a;
 | 
						|
	constructor() {
 | 
						|
		a = 5;
 | 
						|
	}
 | 
						|
	function f() public view returns (uint) { return a; }
 | 
						|
}
 | 
						|
contract C {
 | 
						|
	uint immutable a;
 | 
						|
	uint public x;
 | 
						|
	uint public y;
 | 
						|
	constructor() {
 | 
						|
		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());
 | 
						|
	}
 | 
						|
}
 | 
						|
// ----
 | 
						|
// f() -> 3, 7, 5
 | 
						|
// gas irOptimized: 126044
 | 
						|
// gas legacy: 151334
 | 
						|
// gas legacyOptimized: 125166
 | 
						|
// x() -> 7
 | 
						|
// y() -> 5
 |