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

[analyzer] add warning when abstract interface class has unused implementation. #55641

Open
mmcdon20 opened this issue May 3, 2024 · 0 comments
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 type-enhancement A request for a change that isn't a bug

Comments

@mmcdon20
Copy link

mmcdon20 commented May 3, 2024

@lrhn mentioned in dart-lang/language#3736:

The analyzer should be able to tell you if an abstract interface class has implementation, and it's never extended inside the same library. If it doesn't today, it's at least a possibility.

Consider the following example:

abstract interface class Vehicle {
  final String make;
  final String model;
  Vehicle(this.make, this.model);
  
  void moveForward() {
    print('$make $model is moving forward!');
  }
}

If there are no classes in the same library that extend this interface then the implementation, the body of moveForward and the constructor Vehicle are effectively unreachable code. The analyzer should provide a warning about this, but does not currently.

@lrhn lrhn added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-enhancement A request for a change that isn't a bug labels May 7, 2024
@srawlins srawlins added analyzer-warning Issues with the analyzer's Warning codes P2 A bug or feature request we're likely to work on labels May 13, 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 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants