Do not require overriding for functions in common base with unique implementation.

This commit is contained in:
Daniel Kirchner
2019-12-09 16:04:45 +01:00
committed by chriseth
parent 071a52f0ff
commit 4c7f9f9751
12 changed files with 264 additions and 57 deletions
@@ -0,0 +1,20 @@
interface I {
function f() external;
function g() external;
}
interface J {
function f() external;
}
abstract contract A is I, J {
function f() external override (I, J) {}
function g() external override virtual;
}
abstract contract B is I {
function f() external override virtual;
function g() external override {}
}
contract C is A, B {
}
// ----
// TypeError: (342-364): Derived contract must override function "f". Function with the same name and parameter types defined in two or more base classes.
// TypeError: (342-364): Derived contract must override function "g". Function with the same name and parameter types defined in two or more base classes.
@@ -0,0 +1,17 @@
interface I {
function f() external;
function g() external;
}
interface J {
function f() external;
}
abstract contract A is I, J {
function f() external override (I, J) {}
}
abstract contract B is I {
function g() external override {}
}
contract C is A, B {
}
// ----
// TypeError: (254-276): Derived contract must override function "f". Function with the same name and parameter types defined in two or more base classes.
@@ -0,0 +1,12 @@
contract A {
function f() external virtual {}
}
contract B {
function f() external virtual {}
}
contract C is A, B {
function f() external override (A, B) {}
}
contract X is C {
}
// ----
@@ -0,0 +1,17 @@
interface I {
function f() external;
function g() external;
}
abstract contract A is I {
function f() external override {}
function g() external override virtual;
}
abstract contract B is I {
function g() external override {}
function f() external override virtual;
}
contract C is A, B {
}
// ----
// TypeError: (292-314): Derived contract must override function "f". Function with the same name and parameter types defined in two or more base classes.
// TypeError: (292-314): Derived contract must override function "g". Function with the same name and parameter types defined in two or more base classes.
@@ -0,0 +1,12 @@
interface I {
function f() external;
function g() external;
}
abstract contract A is I {
function f() external override {}
}
abstract contract B is I {
function g() external override {}
}
contract C is A, B {
}
@@ -0,0 +1,13 @@
abstract contract A {
function f() external {}
function g() external virtual;
}
abstract contract B {
function g() external {}
function f() external virtual;
}
contract C is A, B {
}
// ----
// TypeError: (176-198): Derived contract must override function "f". Function with the same name and parameter types defined in two or more base classes.
// TypeError: (176-198): Derived contract must override function "g". Function with the same name and parameter types defined in two or more base classes.
@@ -0,0 +1,19 @@
interface I {
function f() external;
function g() external;
}
interface J {
function f() external;
}
abstract contract IJ is I, J {
function f() external virtual override (I, J);
}
abstract contract A is IJ
{
function f() external override {}
}
abstract contract B is IJ
{
function g() external override {}
}
contract C is A, B {}
@@ -0,0 +1,6 @@
contract A { function f() public pure virtual {} }
contract B is A { function f() public pure virtual override {} }
contract C is A, B { }
contract D is A, B { function f() public pure override(A, B) {} }
// ----
// TypeError: (116-138): Derived contract must override function "f". Function with the same name and parameter types defined in two or more base classes.
@@ -0,0 +1,5 @@
abstract contract A { function f() public pure virtual; }
contract B is A { function f() public pure virtual override {} }
contract C is A, B { }
contract D is A, B { function f() public pure override(A, B) {} }
// ----