Skip to content

[Class modifiers] Report a diagnostic when @reopen is placed on a class which hasn't reopened anything #51592

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
srawlins opened this issue Mar 1, 2023 · 4 comments
Assignees
Labels
devexp-warning Issues with the analyzer's Warning codes legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on
Milestone

Comments

@srawlins
Copy link
Member

srawlins commented Mar 1, 2023

It'd be good to have a diagnostic for no-op @reopen annotations. Generally, it would report on any @reopen annotation which is attached to a class (or mixin?) which does not reopen anything. (@reopen annotations on things other than classes should already be reported as INVALID_ANNOTATION_TARGET.)

Examples:

// library lib1.dart
interface class Interface1 {}
// library lib2.dart
import 'lib1.dart';

interface class Interface2 {}

// WARNING: Does not re-open anything.
@reopen class C1 {}

// WARNING: Does not re-open anything, as it is illegal to extend Interface1 here.
@reopen class C3 extends Interface1 {}

CC @pq @bwilkerson

@srawlins srawlins added legacy-area-analyzer Use area-devexp instead. devexp-warning Issues with the analyzer's Warning codes labels Mar 1, 2023
@srawlins srawlins added this to the Dart 3 beta 3 milestone Mar 1, 2023
@pq pq added the P2 A bug or feature request we're likely to work on label Mar 1, 2023
@pq
Copy link
Member

pq commented Mar 2, 2023

/fyi @kallentu: if we captured information about induced modifiers in the element model, this is something we could neatly implement. Moreover, if we cached this data, we could do it quickly.

@kallentu kallentu changed the title Report a diagnostic when @reopen is placed on a class which hasn't reopened anything [Class modifiers] Report a diagnostic when @reopen is placed on a class which hasn't reopened anything Mar 2, 2023
@pq
Copy link
Member

pq commented Mar 21, 2023

Bumping this to the next milestone for future assessment. Landing @reopen at all is enough of a stretch IMO. (See #58976.)

@pq pq modified the milestones: Dart 3 beta 3, Dart 3 stable Mar 21, 2023
@srawlins
Copy link
Member Author

Mind if I take this one, Phil?

@pq
Copy link
Member

pq commented Mar 28, 2023

Not at all. Go for it!

@pq pq removed their assignment Mar 28, 2023
copybara-service bot pushed a commit that referenced this issue Mar 29, 2023
This is just a clean up before more logic will be added to this
verification.

This clean up allows more single-purpose functions, and helper
functions to be located closer to the functions they help (as we
enforce an alphabetical ordering).

Bug: #51592
Change-Id: I7580deaaf00ca3731bf5de4e3ac53055aa81f99f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291589
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Samuel Rawlins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-warning Issues with the analyzer's Warning codes legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

2 participants