Skip to content

Commit 8cb002f

Browse files
authored
[extension types] Member conflicts ignore precluded members (#3486)
Adjust the rules about extension type member conflicts: precluded members do not create conflicts. This PR changes the rule about member conflicts such that a member which is precluded does not conflict with any other members. It is an adjustment of the rules added by #3470. For example, if an extension type `E1` declares a method named `m` and an extension type `E2` declares a setter named `m=` and has `implements E1`, then `E2` does not "inherit" the method named `m` (it is precluded because it would conflict with the setter). In this PR we add an extra rule which says that it is not a conflict if `E2` has two superinterfaces `E1a` and `E1b`, and `E1a` declares a method named `m` and `E1b` declares a getter named `m`, and `E2` again declares a setter named `m=` and has `implements E1a, E1b`. The point as that `E2` will "inherit" the getter (so it has a full setter/getter pair), but not the method (because it is precluded by the setter), and (here comes the new thing) the method is ignored during conflict checks because it is precluded, so we avoid the useless error about `m` being ambiguous that we'd otherwise have because of `implements E1a, E1b`.
1 parent 34f4818 commit 8cb002f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

accepted/future-releases/extension-types/feature-specification.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,9 @@ On the other hand, it can occur in other ways, e.g., as a type argument of
906906
a superinterface of a class.*
907907

908908
It is a compile-time error if _DV_ is an extension type declaration, and
909-
_DV_ has a non-extension type member named `m` as well as an extension type
910-
member named `m`, for any `m`. *In case of conflicts, _DV_ must declare a
909+
_DV_ has a non-extension type member named `m` which is not precluded by
910+
_DV_ as well as an extension type member named `m` which is not precluded
911+
by _DV_, for any `m`. *In case of conflicts, _DV_ must declare a
911912
member named `m` to resolve the conflict.*
912913

913914
It is a compile-time error if _DV_ is an extension type declaration, and
@@ -918,8 +919,8 @@ conflict.*
918919

919920
A compile-time error occurs if an extension type declaration _DV_ has
920921
two extension type superinterfaces `V1` and `V2`, and both `V1` and `V2`
921-
has an extension type member named `m`, and the two members have distinct
922-
declarations.
922+
has an extension type member named `m` that is not precluded by _DV_, and
923+
the two members have distinct declarations.
923924

924925
*In other words, an extension type member conflict is always an error, even
925926
in the case where they agree perfectly on the types. _DV_ must override the

0 commit comments

Comments
 (0)