Skip to content

Hint if a final field "overrides" non-final field #25567

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

Closed
asgerf opened this issue Jan 23, 2016 · 2 comments
Closed

Hint if a final field "overrides" non-final field #25567

asgerf opened this issue Jan 23, 2016 · 2 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. 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

@asgerf
Copy link
Contributor

asgerf commented Jan 23, 2016

If a final field "overrides" a non-final field, the setter for the superfield becomes a black hole eating all values assigned to the field, never to be seen again.

For extra style points, the hint could be omitted if the setter is also explicitly overridden and/or the super field is accessed using super, because that indicates the user knows what he is doing. Without those indicators, I would argue it is certainly a bug, and we could save the user from one of those "wtf moments" that Dart wasn't supposed to have.

Of course, using fields to "override" other fields is kind of a grotesque coding style in general, so it might be better to just always hint about this.

@asgerf asgerf added type-enhancement legacy-area-analyzer Use area-devexp instead. devexp-warning Issues with the analyzer's Warning codes labels Jan 23, 2016
@bwilkerson bwilkerson added Priority-Medium devexp-linter Issues with the analyzer's support for the linter package and removed devexp-warning Issues with the analyzer's Warning codes labels Jan 23, 2016
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed Priority-Medium labels Mar 1, 2016
@alexeieleusis
Copy link
Contributor

Sent a CL for review https://codereview.chromium.org/1870423002

@pq
Copy link
Member

pq commented Jan 21, 2019

@alexeieleusis's lint landed a while ago so closing out.

Docs here:

http://dart-lang.github.io/linter/lints/overridden_fields.html

👍

@pq pq closed this as completed Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. 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

5 participants