Skip to content

unused_element false-positive when using super parameters on private classes #58750

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
mateusfccp opened this issue May 30, 2022 · 1 comment
Closed
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.

Comments

@mateusfccp
Copy link
Contributor

mateusfccp commented May 30, 2022

Describe the issue
Consider the following code:

class _MyWidget extends StatelessWidget {
  const _MyWidget({Key? key}) : super(key: key);

  // ...
}

This code won't trigger any info/warning.

However, if I use super parameters instead:

class _MyWidget extends StatelessWidget {
  const _MyWidget({super.key});

  // ...
}

The following info will be issued:
info: A value for optional parameter 'key' isn't ever given. (unused_element at [...] lib/...)

To Reproduce
Use the code above with Dart 2.17+ and unused_elements enabled.

Expected behavior
The linter should behave equally for both codes, as they are virtually the same. When using super parameters, however, the linter will incorrectly fire an info.

Additional context:
This issue, obviously, won't happen if the class is public.

Possible workaround:
A possible workaround is to provide a value, like ({super.key = null}). However, it does conflict with avoid_init_to_null.

@mateusfccp mateusfccp changed the title unused_elements false-positive when using super parameters on private classes unused_element false-positive when using super parameters on private classes May 30, 2022
@mateusfccp
Copy link
Contributor Author

Duplicate of #49025.

@mateusfccp mateusfccp closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2022
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
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.
Projects
None yet
Development

No branches or pull requests

2 participants