Skip to content

proposal: annotate_redeclares #59297

Description

@pq

annotate_redeclares

Description

Annotate redeclared members.

Details

DO annotate redeclared members.

This practice improves code readability and helps protect against unintentionally redeclaring members or being surprised when a member ceases to redeclare (due for example to a rename refactoring).

Kind

Style and errors.

Bad Examples

class C { 
  void f() { }
}

extension type E(C c) implements C {
  void f() {
    ...
  }
}

Good Examples

import 'package:meta/meta.dart';

class C { 
  void f() { }
}

extension type E(C c) implements C {
  @redeclare
  void f() {
    ...
  }
}

Discussion

This is essentially an analog to annotate_overrides.

Discussion checklist

  • List any existing rules this proposal modifies, complements, overlaps or conflicts with.
  • List any relevant issues (reported here, the SDK Tracker, or elsewhere).
  • If there's any prior art (e.g., in other linters), please add references here.
  • If this proposal corresponds to Effective Dart or Flutter Style Guide advice, please call it out. (If there isn't any corresponding advice, should there be?)
  • If this proposal is motivated by real-world examples, please provide as many details as you can. Demonstrating potential impact is especially valuable.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions