Skip to content
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

prefer_void_to_null false positive for extension types #59308

Closed
Tracked by #58838
lrhn opened this issue Sep 26, 2023 · 2 comments
Closed
Tracked by #58838

prefer_void_to_null false positive for extension types #59308

lrhn opened this issue Sep 26, 2023 · 2 comments
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive linter-set-recommended P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@lrhn
Copy link
Member

lrhn commented Sep 26, 2023

Example:

extension type B<T>(T? _) {}
extension type N(Null _) implements B<Never> {}

which yields the info:

Analyzing badwarn.dart...

   info - badwarn.dart:2:18 - Unnecessary use of the type 'Null'.
          Try using 'void' instead. - prefer_void_to_null

1 issue found.

Since changing Null to void would be a compile-time error, extension type representation types might not be the best place to apply that info.
(Any time a type has to be a subtype of some other type, suggesting void instead of Null risks being invalid.)

@lrhn lrhn added the type-enhancement A request for a change that isn't a bug label Sep 26, 2023
@eernstg
Copy link
Member

eernstg commented Sep 26, 2023

With null safety, prefer_void_to_null could be obsolete entirely. Cf. #59309.

@pq pq transferred this issue from dart-lang/sdk Sep 26, 2023
@pq pq changed the title Analyzer misplaced "use void instead of Null" warning for extension type. prefer_void_to_null false positive for extension types Sep 26, 2023
@pq pq added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P2 A bug or feature request we're likely to work on and removed type-enhancement A request for a change that isn't a bug labels Sep 26, 2023
@pq
Copy link
Member

pq commented Oct 11, 2023

Fixed w/ d9731ac

@pq pq closed this as completed Oct 11, 2023
@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 20, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive linter-set-recommended P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants