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

Import name conflicts: Suggest adding "hide" on one of the conflicting imports #56255

Open
rrousselGit opened this issue Jul 16, 2024 · 1 comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@rrousselGit
Copy link

Consider:

// a.dart
class Foo {}

// b.dart
class Foo {}

// c.dart
import 'a.dart';
import 'b.dart';

void main() {
  Foo(); // Conflict, defined in both `a.dart` and `b.dart`
}

Going through imports to manually add that hide Foo; on the relevant import is tedious.

Could we add a quick fix for it? When applied on Foo(), it could suggest:

  • Add hide Foo to import 'a.dart'
  • Add hide Foo to import 'b.dart'

Supporting static extensions conflicts too would be great.

@dart-github-bot
Copy link
Collaborator

Summary: The issue is that importing multiple libraries with the same class name (Foo) leads to a conflict. The user suggests adding a quick fix to automatically suggest adding hide Foo to one of the conflicting imports when the user encounters the conflict.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug labels Jul 16, 2024
@srawlins srawlins added the P3 A lower priority bug or feature request label Jul 17, 2024
@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants