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

[linter] Super initialization with optional parameter leads to unused_element #55720

Open
srujzs opened this issue May 14, 2024 · 1 comment
Open
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on

Comments

@srujzs
Copy link
Contributor

srujzs commented May 14, 2024

Dart version: Dart SDK version: 3.5.0-edge.eea3bb5c4fbd09b5f1ba662a5ce19f032b6dba15 (main) (Wed May 8 08:13:44 2024 -0700) on "macos_arm64"

Consider the following Dart code:

class _A {
  final String? f;

  _A([this.f]);
}

class _B extends _A {
  _B();
}

class _C extends _A {
  _C(super.f);
}

void main() {
  _B();
  _C('');
}

The above results in an unused_element diagnostic around this.f, even though _C uses it to provide a value for f.

If we replace _C with:

class _C extends _A {
  _C(String f2) : super(f2);
}

The lint goes away. Should the lint not trigger in the super initialization syntax, or is there some better syntax I should be using?

@srujzs srujzs added the analyzer-linter Issues with the analyzer's support for the linter package label May 14, 2024
@bwilkerson
Copy link
Member

The warning should not be produced in this case.

@bwilkerson bwilkerson added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-warning Issues with the analyzer's Warning codes and removed analyzer-linter Issues with the analyzer's support for the linter package labels May 14, 2024
@scheglov scheglov added the P2 A bug or feature request we're likely to work on label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

3 participants