Skip to content

Inlay hints should display inferred type argument #4366

Closed

Description

@Zekfad

Is your feature request related to a problem? Please describe.
It's hard to navigate to inferred type of generics. You have to lookup relevant argument and find type from it.
For now it's only possible to see inferred type from hover popup, but it's just plain text.

Describe the solution you'd like
Inlay hints should show clickable inferred types of generics.

Describe alternatives you've considered
Make hovers interactive? (But that's likely out of scope).

Additional context

Screenshot of current behavior

image

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Jan 28, 2023
  2. DanTup commented on Jan 28, 2023

    @DanTup
    Member

    Do you mean in cases like this?

    foo<T>(T a) {
      foo('');         // Show an inlay hint of `<String>` after `foo` so this reads foo<String>('')
    }
  3. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Jan 28, 2023
  4. added this to the v3.60.0 milestone on Jan 28, 2023
  5. Zekfad commented on Jan 28, 2023

    @Zekfad
    Author

    Hi @DanTup, thanks for fast reply, yes, that's what I meant.

  6. DanTup commented on Feb 21, 2023

    @DanTup
    Member

    I've a change open to add this for type arguments and also list/map/set literals where it was missing before.

    Feb-21-2023 12-36-15

    https://dart-review.googlesource.com/c/sdk/+/284143

  7. Zekfad commented on Feb 21, 2023

    @Zekfad
    Author

    Hi @DanTup, thank you for your work!
    Is there ETA for Preview version with this feature?

    On your screenshot, it infers <int>a: [1,2], shouldn't it be a: <int>[1,2]?

  8. DanTup commented on Feb 21, 2023

    @DanTup
    Member

    The change is in the Dart analysis server in the SDK, so once the review is done and the code landed, it'll be available in main channel builds of the SDK usually within a few hours or so (and Flutter's master branch probably within a few days). I wouldn't recommend using those versions for production work but they're good for testing. Of course the change will also then show up in future dev/beta/stable releases of the SDKs.

  9. DanTup commented on Feb 21, 2023

    @DanTup
    Member
  10. added
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Feb 21, 2023
  11. Zekfad commented on Feb 21, 2023

    @Zekfad
    Author

    Hi @DanTup, on your screenshot, it infers <int>a: [1,2], shouldn't it be a: <int>[1,2]?

  12. DanTup commented on Feb 21, 2023

    @DanTup
    Member

    @Zekfad Oof, yes, I hadn't noticed that (and apparently I didn't write tests when there are both type args and parameter names at the same offset). I will fix, thanks!

  13. reopened this on Feb 21, 2023
  14. DanTup commented on Feb 22, 2023

    @DanTup
    Member
  15. DanTup commented on Feb 22, 2023

    @DanTup
    Member

    Fix landed in dart-lang/sdk@658e34e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions