proposal: abstract_private_class_member
#57140
Labels
analyzer-linter
Issues with the analyzer's support for the linter package
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
linter-lint-proposal
linter-status-pending
P3
A lower priority bug or feature request
type-enhancement
A request for a change that isn't a bug
Description
Don't define an abstract private member within a public class.
Can be fixed by making the field public or adding the
sealed
class modifier.Details
Kind: AVOID
Currently, the following produces zero static analysis warnings:
Marking a field as
abstract
signifies that "subclasses should implement this", so making it private entirely defeats the purpose.Examples
Discussion
If an abstract private field is added to a non-
sealed
public class, there are 3 possibilities:unused_element
rule is triggeredprivate_field_outside_class
#57139)Even though possibility number 3 would never result in an error, I still think it'd be good for this rule to apply: a lack of
sealed
orfinal
indicates that the class can be built upon outside the declaring library, so if the private field provides utility within the library, IMO it should either be refactored or exposed as a public field.Probably low-priority
I've never seen a class with an abstract private field.
The text was updated successfully, but these errors were encountered: