Skip to content

Inlay hints for nested patterns #4712

@Zekfad

Description

@Zekfad

Is your feature request related to a problem? Please describe.
It would be helpful to easily see (and navigate) to inferred types for nested patterns (switch, if-case, destructuring, etc.)
For now it's only possible to navigate to most inner inferred type.

Describe the solution you'd like
Make inlay hints for nested patterns behave like for generics (like #4366)

Describe alternatives you've considered
Not really.

Additional context
Addition to #4624

final class Box<T> {
  const Box(this.value);
  final T value;
}
void main() {
  {
    const boxedBox = Box(Box((1,2)));
    const boxedList = Box([1,2]);

    { // actual (notice that inner pattern is augmented correctly)
      if (boxedBox case Box(value: Box(:final (int, int) value))) {}
      if (boxedList case Box(value: List(:final int length)) when length > 0) {}
    }
    { // expected
      if (boxedBox case Box<Box<(int, int)>>(value: Box<(int, int)>(:final (int, int) value))) {}
      if (boxedList case Box<List<int>>(value: List<int>(:final int length)) when length > 0) {}
    }
  }
}

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 enhancementrelies 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