Skip to content

Commit

Permalink
[extension types] Member conflicts ignore precluded members (#3486)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
eernstg authored Dec 1, 2023
1 parent 34f4818 commit 8cb002f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,9 @@ On the other hand, it can occur in other ways, e.g., as a type argument of
a superinterface of a class.*

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

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

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

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

0 comments on commit 8cb002f

Please sign in to comment.