forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ethereum#7878 from ethereum/overrideUnimplementedW…
…ithBaseImpl Do not require overriding for functions in common base with unique implementation.
- Loading branch information
Showing
15 changed files
with
315 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...libsolidity/syntaxTests/inheritance/override/ambiguous_base_and_unique_implementation.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
17 changes: 17 additions & 0 deletions
17
test/libsolidity/syntaxTests/inheritance/override/ambiguous_base_and_unique_mention.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
12 changes: 12 additions & 0 deletions
12
...axTests/inheritance/override/ambiguous_base_functions_overridden_in_intermediate_base.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
} | ||
// ---- |
15 changes: 15 additions & 0 deletions
15
...tance/override/ambiguous_base_functions_overridden_in_intermediate_base_unimplemented.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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 { | ||
} | ||
// ---- | ||
// TypeError: (120-158): Overriding an implemented function with an unimplemented function is not allowed. | ||
// TypeError: (120-158): Overriding an implemented function with an unimplemented function is not allowed. | ||
// TypeError: (120-158): Functions without implementation must be marked virtual. |
Oops, something went wrong.