Skip to content

Extension instance members highlight doesn't take the exact extension into consideration #60626

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

Open
FMorschel opened this issue Apr 25, 2025 · 3 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. P2 A bug or feature request we're likely to work on

Comments

@FMorschel
Copy link
Contributor

Consider this code:

abstract class C<T> {}

void f(C<int> v, C<String> s) {
  v.foo;
  s.foo;
}

extension on C<int> {
  int get foo => 0;
}

extension on C<String> {
  int get foo => 0;
}

Since both foo have the same signature (if one returned something else this doesn't happen) even though they are used separately, they all highlight together.

I'm unsure how hard it would be for occurrences to take this into consideration but I think we should probably think about fixing this.

Image

This problem persists even with named extensions and extension overrides:

Image

@FMorschel FMorschel added the area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. label Apr 25, 2025
@FMorschel
Copy link
Contributor Author

Okay, this seems to be an even bigger problem than I originally thought. The extended types don't need to be the same. I'll rename the issue.

extension on String {
  int get foo => 0;
}

extension on int {
  int get foo => 0;
}

void f(int v, String s) {
  v.foo;
  s.foo;
}

Image

@FMorschel FMorschel changed the title Extension instance members highlight doesn't take type arguments into consideration Extension instance members highlight doesn't take the exact extension into consideration Apr 25, 2025
@FMorschel
Copy link
Contributor Author

I'm looking into this

@FMorschel
Copy link
Contributor Author

@bwilkerson bwilkerson added the P2 A bug or feature request we're likely to work on label May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

2 participants