Issue state mutability restriction for overriding and not for virtual functions.

This commit is contained in:
chriseth
2020-07-16 17:19:35 +02:00
parent f945163909
commit aa3f51ab47
8 changed files with 31 additions and 16 deletions
@@ -1,10 +1,10 @@
interface Parent {
function test() external returns (uint256);
function test() external pure returns (uint256);
}
interface SubA is Parent {}
interface SubB is Parent {}
contract C is SubA, SubB {
function test() external override returns (uint256) { return 42; }
function test() external override pure returns (uint256) { return 42; }
}
@@ -1,15 +1,15 @@
interface Parent {
function test() external returns (uint256);
function test() external pure returns (uint256);
}
interface SubA is Parent {
function test() external override returns (uint256);
function test() external pure override returns (uint256);
}
interface SubB is Parent {
function test() external override returns (uint256);
function test() external pure override returns (uint256);
}
contract C is SubA, SubB {
function test() external override(SubA, SubB) returns (uint256) { return 42; }
function test() external pure override(SubA, SubB) returns (uint256) { return 42; }
}
@@ -1,17 +1,17 @@
interface ParentA {
function testA() external returns (uint256);
function testA() external pure returns (uint256);
}
interface ParentB {
function testB() external returns (uint256);
function testB() external pure returns (uint256);
}
interface Sub is ParentA, ParentB {
function testSub() external returns (uint256);
function testSub() external pure returns (uint256);
}
contract SubImpl is Sub {
function testA() external override returns (uint256) { return 12; }
function testB() external override(ParentB) returns (uint256) { return 42; }
function testSub() external override returns (uint256) { return 99; }
function testA() external pure override returns (uint256) { return 12; }
function testB() external pure override(ParentB) returns (uint256) { return 42; }
function testSub() external pure override returns (uint256) { return 99; }
}
@@ -0,0 +1,14 @@
contract A {
// no "state mutability can be restricted"-warning here
function foo() external virtual returns (uint) { return 1; }
}
contract B is A {
// no "state mutability can be restricted"-warning here
function foo() external virtual override returns (uint) { return 2; }
}
contract C is B {
// warning is here
function foo() external override returns (uint) { return 3; }
}
// ----
// Warning 2018: (339-400): Function state mutability can be restricted to pure
@@ -5,4 +5,4 @@ contract Bike is Vehicle {
function f(bytes calldata) override external returns (uint256 r) {r = 42;}
}
// ----
// Warning 2018: (23-95): Function state mutability can be restricted to pure
// Warning 2018: (129-203): Function state mutability can be restricted to pure