Skip to content

How should avoid_setters_without_getters handle extension types? #59307

Open
@srawlins

Description

@srawlins

See https://dart.dev/tools/linter-rules/avoid_setters_without_getters. What if we have this:

class C {
  int get x => 1;
}

extension type E(C it) implements C {
  set x(int newValue) => it.x = newValue;
}

Should avoid_setters_without_getters fire on this extension type? I think not... But maybe? Imagine a more realistic example where C subclasses another class D, and the extension type exposes (implements) D, and get x is declared on D.

Also imagine an example where E implements another extension type, and get x is declared on that extension type.

Activity

bwilkerson

bwilkerson commented on Sep 21, 2023

@bwilkerson
Member

The lint's documentation isn't very clear, but it seems to me that the lint shouldn't flag a setter if the members of the container include a getter with the same base name, no matter how the getter is a member (inheritance, exposure, etc.).

added
area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
and removed on Feb 21, 2025
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

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-new-language-featuretype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @pq@srawlins@devoncarew@bwilkerson

        Issue actions

          How should avoid_setters_without_getters handle extension types? · Issue #59307 · dart-lang/sdk