Skip to content

Analyzer auto-completes members on "Never.^" non-ideally #52962

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
matanlurey opened this issue Jul 17, 2023 · 3 comments
Closed

Analyzer auto-completes members on "Never.^" non-ideally #52962

matanlurey opened this issue Jul 17, 2023 · 3 comments
Labels
devexp-completion Issues with the analysis server's code completion feature devexp-ux legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request

Comments

@matanlurey
Copy link
Contributor

Simple example

On most types (i.e. String):

void main() {
  String.^
}

Screenshot 2023-07-17 at 4 43 31 PM

but for Never:

Screenshot 2023-07-17 at 4 44 09 PM

Why file this issue?

Good question. One could say this is such a rare or even unusable concept and the priority of this should be P12. However, this makes using a cute-little namespace pattern in Dart a bit ugly:

extension Fruits on Never {
  const apple = 'apple';
  const grapes = 'grapes';
  const watermelon = 'watermelon';
}

void main() {
  // Auto-completes first with hashCode and runtimeType, and then Fruits.apple third.
  print(Fruits.^);
}
@matanlurey matanlurey changed the title Analyzer shows non-members on auto-completing "Never.^" Analyzer auto-completes members on "Never.^" non-ideally Jul 17, 2023
@lrhn
Copy link
Member

lrhn commented Jul 18, 2023

Not sure I understand the example.
The const declarations are not valid (have to be static, there are no instance constant variables), you can't access statics of an extension through the on type, and you can't access instance getters on a type object.

If they are supposed to be static, I don't think the priority has anything to do with the type Never. But I can be wrong about that.

@matanlurey
Copy link
Contributor Author

you can't access statics of an extension through

Sure you can:

void main() {
  print(Presidents.abe);
}

extension Presidents on Never {
  static const abe = 'Abraham';
  static const george = 'George';
  static const jefferson = 'Jefferson';
}

@lrhn
Copy link
Member

lrhn commented Jul 18, 2023

That's not "through the on type". That's just accessing statics on the extension name directly, so it's not on Never, and should (I hope) not be related to the Never type at all.

I'd expect that it is the same for any extension type, that statics on an extension type hey lower priority than instance methods on the Type object, possibly because extension instance methods get lower precedence than interface instance methods.
(But that is just guessing, until I get to test it.)

@bwilkerson bwilkerson added legacy-area-analyzer Use area-devexp instead. devexp-completion Issues with the analysis server's code completion feature labels Jul 18, 2023
@pq pq added P3 A lower priority bug or feature request devexp-ux labels Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-completion Issues with the analysis server's code completion feature devexp-ux legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

4 participants