8000 [proposal] add an `@unstableGetter` annotation · Issue #53632 · dart-lang/sdk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[proposal] add an @unstableGetter annotation #53632

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
pq opened this issue Sep 27, 2023 · 7 comments
Open

[proposal] add an @unstableGetter annotation #53632

pq opened this issue Sep 27, 2023 · 7 comments
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 devexp-pkg-meta Issues related to package:meta 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

@pq
Copy link
Member
pq commented Sep 27, 2023

More context in #59313.

@eernstg: word-smithing welcome!

@pq pq added legacy-area-analyzer Use area-devexp instead. devexp-linter Issues with the analyzer's support for the linter package P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug devexp-pkg-meta Issues related to package:meta labels Sep 27, 2023
@pq pq self-assigned this Sep 27, 2023
@pq
Copy link
Member Author
pq commented Sep 27, 2023

Here's a sample of an existing annotation that informs a lint. (@eernstg: it should look familiar as IIRC you helped write it!)

/// Annotation for intentionally loosening restrictions on subtyping that would
/// otherwise cause lint warnings to be produced by the `implicit_reopen` lint.
///
/// Indicates that the annotated class, mixin, or mixin class declaration
/// intentionally allows subtypes outside the library to implement it, or extend
/// it, or mix it in, even though it has some superinterfaces whose restrictions
/// prevent inheritance.
///
/// A class, mixin, or mixin class declaration prevents inheritance if:
///
/// * it is marked `interface` or `final`
/// * it is marked `sealed`, and is implicitly `interface` or `final`
///   based on the modifiers of its superinterfaces
/// * it is an anonymous mixin application, and is implicitly `interface` or
///   `final` based on the modifiers of its superinterfaces
///
/// A declaration annotated with `@reopen` will suppress warnings from the
/// [`implicit_reopen`](https://dart.dev/tools/linter-rules/implicit_reopen)
/// lint. That lint will otherwise warn when a subtype has restrictions that are
/// not sufficient to enforce the restrictions declared by class modifiers on
/// one or more superinterfaces.
///
/// In addition, tools, such as the analyzer, can provide feedback if
///
/// * The annotation is applied to anything other than a class, mixin, or mixin
///   class.
/// * The annotation is applied to a class or mixin which does not require it.
///   (The intent to reopen was not satisfied.)

@parlough
Copy link
Member
parlough commented Sep 28, 2023

I guess my concern is not necessarily future conflicts but being accidentally used instead of @experimental. However, that might be a rare mistake that would only happen until the term "stable getter" is more widely familiar and understood.

Also currently, I believe it would render on dart doc pages as @unstable without other information. I imagine that could definitely be mistaken as being an experimental marker.

@eernstg
Copy link
Member
eernstg commented Sep 28, 2023

Perhaps we should make it @unstableGetter after all. That one should be quite informative for anyone who has encountered the concept at all. @lrhn's comment here would still apply, no matter which name is chosen.

@eernstg
Copy link
Member
eernstg commented Sep 28, 2023
/// Annotation for a final instance variable indicating that the implicitly
/// induced getter of that variable is not intended to be stable.
///
/// This annotation is associated with the lint `avoid_unstable_final_fields`,
/// and it has no effect unless that lint is enabled.
///
/// When a final instance variable does not have this annotation, it is assumed
/// to induce a stable getter, and the lint will flag the overriding 
/// declarations that cause this getter to be unstable (that is, the overriding
/// getters which may return different results on different invocations with
/// the same receiver).
/// 
/// When a final instance variable has this annotation, it is not assumed to
/// induce a stable getter, and overriding getters are not flagged, whether or
/// not they are stable.
///
/// Intuitively, this combination of lint and annotation is intended to have the
/// following effect: By default, every final instance variable is an immutable
/// property of the receiver. If a property is declared as a final instance
/// variable, but it is not intended to be immutable then it should have this
/// annotation. The lint will flag locations where this assumption is violated.
///
/// In addition, tools such as the analyzer can provide feedback if the
/// annotation is applied to anything other than a final instance variable.

@bwilkerson
Copy link
Member

Perhaps we should make it @unstableGetter after all.

I'm ok with that.

@pq
Copy link
Member Author
pq commented Sep 28, 2023

Perhaps we should make it @unstableGetter after all.

I'm ok with that.

Me too.

@pq pq changed the title [proposal] add an @unstable annotation [proposal] add an @unstableGetter annotation Sep 28, 2023
@eernstg
Copy link
Member
eernstg commented Oct 11, 2023

See https://dart-review.googlesource.com/c/sdk/+/330101.

@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
@pq pq removed their assignment Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp 489F 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 devexp-pkg-meta Issues related to package:meta 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
0