mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add override exception for interface functions.
This commit is contained in:
@@ -23,8 +23,6 @@ interface Sub is SuperA, SuperB {
|
||||
}
|
||||
|
||||
// ----
|
||||
// TypeError 9456: (572-616): Overriding function is missing "override" specifier.
|
||||
// TypeError 9456: (572-616): Overriding function is missing "override" specifier.
|
||||
// TypeError 4327: (572-616): Function needs to specify overridden contracts "SuperA" and "SuperB".
|
||||
// TypeError 4327: (647-655): Function needs to specify overridden contracts "SuperA" and "SuperB".
|
||||
// TypeError 4327: (705-721): Function needs to specify overridden contract "SuperB".
|
||||
|
||||
@@ -11,4 +11,3 @@ interface Sub is Super {
|
||||
}
|
||||
|
||||
// ----
|
||||
// TypeError 9456: (197-241): Overriding function is missing "override" specifier.
|
||||
|
||||
@@ -6,9 +6,9 @@ interface I {
|
||||
}
|
||||
contract C is I {
|
||||
uint dummy;
|
||||
function f(uint[] memory) public override pure {}
|
||||
function g(uint[] memory) public override view { dummy; }
|
||||
function h(uint[] memory) public override { dummy = 42; }
|
||||
function i(uint[] memory) public override payable {}
|
||||
function f(uint[] memory) public pure {}
|
||||
function g(uint[] memory) public view { dummy; }
|
||||
function h(uint[] memory) public { dummy = 42; }
|
||||
function i(uint[] memory) public payable {}
|
||||
}
|
||||
// ----
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ interface I {
|
||||
function f(uint[] calldata) external pure;
|
||||
}
|
||||
contract A is I {
|
||||
function f(uint[] memory) public override pure {}
|
||||
function f(uint[] memory) public pure {}
|
||||
}
|
||||
contract C {
|
||||
function f() public {
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ interface I {
|
||||
contract C is I {
|
||||
uint dummy;
|
||||
function f(S memory) public override pure {}
|
||||
function g(S memory) public override view { dummy; }
|
||||
function g(S memory) public view { dummy; }
|
||||
function h(S memory) public override { dummy = 42; }
|
||||
function i(S memory) public override payable {}
|
||||
function i(S memory) public payable {}
|
||||
}
|
||||
// ----
|
||||
|
||||
@@ -7,5 +7,4 @@ contract B is I {
|
||||
function f() public pure returns (uint, uint) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9456: (182-230): Overriding function is missing "override" specifier.
|
||||
// TypeError 4822: (182-230): Overriding function return types differ.
|
||||
|
||||
+6
-6
@@ -3,15 +3,15 @@ interface I {
|
||||
function g() external;
|
||||
}
|
||||
abstract contract A is I {
|
||||
function f() external override {}
|
||||
function g() external override virtual;
|
||||
function f() external {}
|
||||
function g() external virtual;
|
||||
}
|
||||
abstract contract B is I {
|
||||
function g() external override {}
|
||||
function f() external override virtual;
|
||||
function g() external {}
|
||||
function f() external virtual;
|
||||
}
|
||||
contract C is A, B {
|
||||
}
|
||||
// ----
|
||||
// TypeError 6480: (292-314): Derived contract must override function "f". Two or more base classes define function with same name and parameter types.
|
||||
// TypeError 6480: (292-314): Derived contract must override function "g". Two or more base classes define function with same name and parameter types.
|
||||
// TypeError 6480: (256-278): Derived contract must override function "f". Two or more base classes define function with same name and parameter types.
|
||||
// TypeError 6480: (256-278): Derived contract must override function "g". Two or more base classes define function with same name and parameter types.
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@ interface I {
|
||||
function g() external;
|
||||
}
|
||||
abstract contract A is I {
|
||||
function f() external override {}
|
||||
function f() external {}
|
||||
}
|
||||
abstract contract B is I {
|
||||
function g() external override {}
|
||||
function g() external {}
|
||||
}
|
||||
contract C is A, B {
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ interface I {
|
||||
}
|
||||
abstract contract A is I
|
||||
{
|
||||
uint public override f;
|
||||
uint public f;
|
||||
}
|
||||
abstract contract B is I
|
||||
{
|
||||
|
||||
+3
-3
@@ -3,12 +3,12 @@ interface I {
|
||||
}
|
||||
contract A is I
|
||||
{
|
||||
uint public override f;
|
||||
uint public f;
|
||||
}
|
||||
abstract contract B is I
|
||||
{
|
||||
function f() external virtual override returns (uint);
|
||||
function f() external virtual returns (uint);
|
||||
}
|
||||
abstract contract C is A, B {}
|
||||
// ----
|
||||
// TypeError 6480: (185-215): Derived contract must override function "f". Two or more base classes define function with same name and parameter types. Since one of the bases defines a public state variable which cannot be overridden, you have to change the inheritance layout or the names of the functions.
|
||||
// TypeError 6480: (167-197): Derived contract must override function "f". Two or more base classes define function with same name and parameter types. Since one of the bases defines a public state variable which cannot be overridden, you have to change the inheritance layout or the names of the functions.
|
||||
|
||||
+3
-3
@@ -3,12 +3,12 @@ interface I {
|
||||
}
|
||||
contract A is I
|
||||
{
|
||||
uint public override f;
|
||||
uint public f;
|
||||
}
|
||||
abstract contract B is I
|
||||
{
|
||||
function f() external virtual override returns (uint) { return 2; }
|
||||
function f() external virtual returns (uint) { return 2; }
|
||||
}
|
||||
abstract contract C is A, B {}
|
||||
// ----
|
||||
// TypeError 6480: (198-228): Derived contract must override function "f". Two or more base classes define function with same name and parameter types. Since one of the bases defines a public state variable which cannot be overridden, you have to change the inheritance layout or the names of the functions.
|
||||
// TypeError 6480: (180-210): Derived contract must override function "f". Two or more base classes define function with same name and parameter types. Since one of the bases defines a public state variable which cannot be overridden, you have to change the inheritance layout or the names of the functions.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
interface ERC20 { function x() external returns (uint); }
|
||||
contract C is ERC20 { uint public override x; }
|
||||
contract C is ERC20 { uint public x; }
|
||||
// ----
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
interface X { function test() external returns (uint256); }
|
||||
contract Y is X {
|
||||
uint256 public override test = 42;
|
||||
uint256 public test = 42;
|
||||
}
|
||||
contract T {
|
||||
constructor() { new Y(); }
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
abstract contract I {
|
||||
function f() external virtual;
|
||||
}
|
||||
contract C is I {
|
||||
function f() external {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9456: (75-99): Overriding function is missing "override" specifier.
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
interface I {
|
||||
function f() external;
|
||||
function g() external;
|
||||
function h() external;
|
||||
}
|
||||
interface J {
|
||||
function f() external;
|
||||
function g() external;
|
||||
function h() external;
|
||||
}
|
||||
contract C is I, J {
|
||||
function f() external {}
|
||||
function g() external override {}
|
||||
function h() external override(I) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4327: (198-222): Function needs to specify overridden contracts "I" and "J".
|
||||
// TypeError 4327: (246-254): Function needs to specify overridden contracts "I" and "J".
|
||||
// TypeError 4327: (281-292): Function needs to specify overridden contract "J".
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface I {
|
||||
function f() external;
|
||||
function g() external;
|
||||
function h() external;
|
||||
}
|
||||
contract C is I {
|
||||
function f() external {}
|
||||
function g() external override {}
|
||||
function h() external override(I) {}
|
||||
}
|
||||
// ----
|
||||
@@ -1,9 +1,11 @@
|
||||
interface A {
|
||||
function test() external returns (uint256);
|
||||
function test2() external returns (uint256);
|
||||
function test3() external returns (uint256);
|
||||
}
|
||||
contract X is A {
|
||||
function test() external override returns (uint256) {}
|
||||
function test2() external override(A) returns (uint256) {}
|
||||
function test3() external returns (uint256) {}
|
||||
}
|
||||
// ----
|
||||
|
||||
+4
-4
@@ -11,11 +11,11 @@ contract X is A, B {
|
||||
function goo() external virtual override(A, B) returns (uint) {}
|
||||
}
|
||||
abstract contract T is A {
|
||||
function foo() external virtual override returns (uint);
|
||||
function goo() external virtual override returns (uint);
|
||||
function foo() external virtual returns (uint);
|
||||
function goo() external virtual returns (uint);
|
||||
}
|
||||
contract Y is X, T {
|
||||
}
|
||||
// ----
|
||||
// TypeError 6480: (484-506): Derived contract must override function "foo". Two or more base classes define function with same name and parameter types. Since one of the bases defines a public state variable which cannot be overridden, you have to change the inheritance layout or the names of the functions.
|
||||
// TypeError 6480: (484-506): Derived contract must override function "goo". Two or more base classes define function with same name and parameter types.
|
||||
// TypeError 6480: (466-488): Derived contract must override function "foo". Two or more base classes define function with same name and parameter types. Since one of the bases defines a public state variable which cannot be overridden, you have to change the inheritance layout or the names of the functions.
|
||||
// TypeError 6480: (466-488): Derived contract must override function "goo". Two or more base classes define function with same name and parameter types.
|
||||
|
||||
Reference in New Issue
Block a user