mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
FunctionDefinition.resolveVirtual(): Skip unimplemented functions when lookup happens via super
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
abstract contract I {
|
||||
function a() internal view virtual returns(uint256);
|
||||
}
|
||||
|
||||
abstract contract C is I {
|
||||
function f() public view returns(uint256) {
|
||||
return I.a();
|
||||
}
|
||||
}
|
||||
|
||||
abstract contract D is I {
|
||||
function f() public view returns(uint256) {
|
||||
return super.a();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7501: (172-177): Cannot call unimplemented base function.
|
||||
// TypeError 9582: (278-285): Member "a" not found or not visible after argument-dependent lookup in type(contract super D).
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract A {
|
||||
function f() public virtual {}
|
||||
}
|
||||
abstract contract B {
|
||||
function f() public virtual;
|
||||
}
|
||||
contract C is A, B {
|
||||
function f() public virtual override(A, B) {
|
||||
B.f(); // Should not skip over to A.f() just because B.f() has no implementation.
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7501: (185-190): Cannot call unimplemented base function.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
contract A {
|
||||
function f() public virtual {}
|
||||
}
|
||||
abstract contract B {
|
||||
function f() public virtual;
|
||||
}
|
||||
contract C is A, B {
|
||||
function f() public override(A, B) {
|
||||
super.f(); // super should skip the unimplemented B.f() and call A.f() instead.
|
||||
}
|
||||
}
|
||||
// ----
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
contract A {
|
||||
function f() public virtual {}
|
||||
}
|
||||
abstract contract B {
|
||||
function f() public virtual;
|
||||
}
|
||||
contract C is A, B {
|
||||
function f() public override(A, B) {
|
||||
// This is fine. The unimplemented B.f() is not used.
|
||||
}
|
||||
}
|
||||
// ----
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract A {
|
||||
function f() public virtual {}
|
||||
}
|
||||
abstract contract B {
|
||||
function f() public virtual;
|
||||
}
|
||||
abstract contract C is A, B {
|
||||
function g() public {
|
||||
f(); // Would call B.f() if we did not require an override in C.
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 6480: (107-243): Derived contract must override function "f". Two or more base classes define function with same name and parameter types.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
contract A {
|
||||
function f() public virtual {}
|
||||
}
|
||||
abstract contract B is A {
|
||||
function f() public virtual override;
|
||||
}
|
||||
contract C is B {
|
||||
function f() public virtual override {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4593: (81-118): Overriding an implemented function with an unimplemented function is not allowed.
|
||||
Reference in New Issue
Block a user