Skip to content

Convert Getter to Method refactor wrong behaviour with pattern destructuring #62139

@FMorschel

Description

@FMorschel

Repro:

class C {
  int? get foo => null;
}

void f(C c) {
  if (c case C(:final foo)) {}
}

Gets refactored into:

class C {
  int? foo() => null;
}

void f(C c) {
  if (c case C(():final foo)) {}
}

The (): syntax is invalid and an unnecessary change. We should be adding () wherever the local variable is being used instead. I'll take a look at this.

FYI @bwilkerson @srawlins @DanTup

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions