sdk icon indicating copy to clipboard operation
sdk copied to clipboard

`Convert Getter to Method` refactor wrong behaviour with pattern destructuring

Open FMorschel opened this issue 1 week ago • 2 comments

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

FMorschel avatar Dec 01 '25 13:12 FMorschel