Skip to content

How should avoid_setters_without_getters handle extension types? #59307

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

Open
srawlins opened this issue Sep 21, 2023 · 1 comment
Open

How should avoid_setters_without_getters handle extension types? #59307

srawlins opened this issue Sep 21, 2023 · 1 comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-new-language-feature P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@srawlins
Copy link
Member

See https://dart.dev/tools/linter-rules/avoid_setters_without_getters. What if we have this:

class C {
  int get x => 1;
}

extension type E(C it) implements C {
  set x(int newValue) => it.x = newValue;
}

Should avoid_setters_without_getters fire on this extension type? I think not... But maybe? Imagine a more realistic example where C subclasses another class D, and the extension type exposes (implements) D, and get x is declared on D.

Also imagine an example where E implements another extension type, and get x is declared on that extension type.

@bwilkerson
Copy link
Member

The lint's documentation isn't very clear, but it seems to me that the lint shouldn't flag a setter if the members of the container include a getter with the same base name, no matter how the getter is a member (inheritance, exposure, etc.).

@pq pq added P2 A bug or feature request we're likely to work on linter-new-language-feature labels Sep 25, 2023
@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Apr 12, 2024
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 20, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 20, 2024
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-new-language-feature P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants