sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[False positive] `unused_element` flags private setter in subclass as unused

Open Pante opened this issue 3 days ago • 0 comments

Dart SDK version: 3.10.3

The following code snippet produces a false positive:

class A {
  int get _value => 0;

  set _value(int v) {
    print('A');
  }
}

extension E on A {
  set value(int v) => _value = v;
}

class B extends A {
  @override
  set _value(int v) { // Flags setter as unused_element even though it's used in the extension.
    print('B');
  }
}

void main() {
  A().value = 1;
  B().value = 1;
}

Pante avatar Dec 08 '25 13:12 Pante