mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests after making all explicit address conversions as non-payable
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ contract B {
|
||||
A a;
|
||||
|
||||
fallback() external {
|
||||
address(a).transfer(100);
|
||||
payable(a).transfer(100);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ contract C {
|
||||
return 1;
|
||||
}
|
||||
function transfer(uint amount) public {
|
||||
address(this).transfer(amount); // to avoid pureness warning
|
||||
payable(this).transfer(amount); // to avoid pureness warning
|
||||
}
|
||||
receive() payable external {
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ contract B {
|
||||
}
|
||||
S s;
|
||||
function f() public {
|
||||
s.a = address(this);
|
||||
s.a = payable(this);
|
||||
}
|
||||
receive() external payable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
function f() public pure returns (C c) {
|
||||
c = C(payable(2));
|
||||
c = C(payable(address(2)));
|
||||
}
|
||||
receive() external payable {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function f() public view {
|
||||
address a1 = address(uint160(0));
|
||||
address a2 = address(bytes20(0));
|
||||
address a3 = address(this);
|
||||
|
||||
address payable a4 = payable(uint160(0));
|
||||
address payable a5 = payable(bytes20(0));
|
||||
address payable a6 = payable(this);
|
||||
|
||||
// Trivial conversions
|
||||
address payable a7 = payable(address(uint160(0)));
|
||||
address payable a8 = payable(address(bytes20(0)));
|
||||
address payable a9 = payable(address(this));
|
||||
|
||||
a1; a2; a3; a4; a5; a6; a7; a8; a9;
|
||||
}
|
||||
|
||||
// to make payable(this) work
|
||||
receive() payable external {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
address payable a = address(uint160(0));
|
||||
address payable b = address(bytes20(0));
|
||||
address payable c = address(this);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9574: (52-91): Type address is not implicitly convertible to expected type address payable.
|
||||
// TypeError 9574: (101-140): Type address is not implicitly convertible to expected type address payable.
|
||||
// TypeError 9574: (150-183): Type address is not implicitly convertible to expected type address payable.
|
||||
@@ -1,5 +1,5 @@
|
||||
contract C {
|
||||
function f(bytes20 x) public pure returns (address payable) {
|
||||
return address(x);
|
||||
return payable(x);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
function f() public view {
|
||||
address payable a = address(this);
|
||||
address payable a = payable(this);
|
||||
a;
|
||||
}
|
||||
fallback() external payable {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
function f() public view {
|
||||
address payable a = address(this);
|
||||
address payable a = payable(this);
|
||||
a;
|
||||
}
|
||||
receive() external payable {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
address payable a = payable(address(new D()));
|
||||
address payable b = payable(new E());
|
||||
address payable c = payable(new F());
|
||||
|
||||
a;
|
||||
b;
|
||||
c;
|
||||
}
|
||||
}
|
||||
|
||||
// A contract that cannot receive Ether
|
||||
contract D {}
|
||||
|
||||
// A contract that can receive Ether
|
||||
contract E {
|
||||
receive() external payable {
|
||||
}
|
||||
}
|
||||
|
||||
// A contract that can receive Ether using the fallback
|
||||
contract F {
|
||||
fallback() external payable {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
address payable a = address(new D());
|
||||
|
||||
// This conversion makes no sense anyway.
|
||||
address payable b = address(D);
|
||||
}
|
||||
}
|
||||
|
||||
contract D {
|
||||
receive() external payable {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9574: (47-83): Type address is not implicitly convertible to expected type address payable.
|
||||
// TypeError 9640: (164-174): Explicit type conversion not allowed from "type(contract D)" to "address".
|
||||
// TypeError 9574: (144-174): Type address is not implicitly convertible to expected type address payable.
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
function f() public pure returns (C c) {
|
||||
c = C(payable(2));
|
||||
}
|
||||
receive() external payable {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -1,5 +1,5 @@
|
||||
contract C {
|
||||
function f(uint x) public pure returns (address payable) {
|
||||
return address(uint160(x));
|
||||
return payable(uint160(x));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
address(this).transfer(1);
|
||||
require(address(this).send(2));
|
||||
selfdestruct(address(this));
|
||||
payable(this).transfer(1);
|
||||
require(payable(this).send(2));
|
||||
selfdestruct(payable(this));
|
||||
(bool success,) = address(this).delegatecall("");
|
||||
require(success);
|
||||
(success,) = address(this).call("");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
contract C {
|
||||
function f() view public {
|
||||
address(this).transfer(1);
|
||||
payable(this).transfer(1);
|
||||
}
|
||||
function g() view public {
|
||||
require(address(this).send(2));
|
||||
require(payable(this).send(2));
|
||||
}
|
||||
function h() view public {
|
||||
selfdestruct(address(this));
|
||||
selfdestruct(payable(this));
|
||||
}
|
||||
function i() view public {
|
||||
(bool success,) = address(this).delegatecall("");
|
||||
|
||||
Reference in New Issue
Block a user