dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.25k stars 1.58k forks source link

Feature request: expanded usage for `@reopen` #57094

Open nate-thegrate opened 5 hours ago

nate-thegrate commented 5 hours ago

When a @protected method (such as State.dispose) is overridden, it loses its "protected" status unless the annotation is re-applied.

This has resulted in some less-than-ideal Flutter autofill suggestions:

navigator dispose


Proposal

Maybe the @reopen annotation's usage could be expanded to cover class fields as well: restrictive annotations like @protected would apply to any subtype's overridden fields by default, unless the field is "re-opened".

(Would an analyzer change like this one count as "breaking"?)

dart-github-bot commented 5 hours ago

Summary: The user proposes expanding the @reopen annotation to apply to class fields, allowing developers to maintain the protected status of overridden fields in subtypes. This would address the issue of overridden protected methods losing their protected status, leading to unintended autofill suggestions.

nate-thegrate commented 5 hours ago

In case it helps with issue triage: I have an open PR to manually re-add annotations to each public State subtype's overridden methods, which would solve the problem with regards to Navigator.of(context).