Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[extension types] Member conflicts ignore precluded members #3486

Merged
merged 2 commits into from
Dec 1, 2023

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Nov 28, 2023

See dart-lang/sdk#53719 (comment) for some background.

This PR adds rules to specify that a precluded member does not contribute to a conflict. This is a small adjustment to the rules which were added in #3470.

For example:

extension type E1(int it) {
  void foo() {}
}

extension type E2(int it) {
  int get foo => 0;
}

extension type E3(int it) implements E1, E2 {
  set foo(_) {} // No setter/method conflict occurs here.
}

void main() {
  var e3 = E3(1);
  e3.foo = true; // OK, `E3` has this setter.
  e3.foo; // OK, `E3` has this getter.
  e3.foo(); // Error, `E3` does not have this method, and the getter doesn't return a function.
}

The rationale is as follows: If E3 had had implements E1 then E3 would have had the setter named foo= and it would not have had the method named foo, because it is precluded. With implements E2, E3 would have had the setter and the getter, and there is no conflict (and no error). Hence, we might as well let E3 have the setter and the getter when it has implements E1, E2, because the consistent choice is in any case that E3 has the getter and not the method, so there is no ambiguity in E3 about the meaning of foo.

@eernstg
Copy link
Member Author

eernstg commented Nov 30, 2023

Hi @jakemac53, could you take a look at this one? It's a correction to the rules about precluding an "otherwise-inherited" member of an extension type that were introduced in #3470.

Copy link
Contributor

@jakemac53 jakemac53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry its been a busy week, LGTM :)

@eernstg
Copy link
Member Author

eernstg commented Dec 1, 2023

NP, thanks! ;-)

@eernstg eernstg merged commit 8cb002f into main Dec 1, 2023
3 checks passed
@eernstg eernstg deleted the spec_extension_type_shadow2_nov23 branch December 1, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants