-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: add lint or collection of lints to detect when using interfaces in an impure way. #4963
Comments
it's not a lint I'd want in the recommended set. That is, it's a style lint that one can opt in to, but not an official style recommendation. About the individual points of warning:
Should be "concrete instance field declaration". A declaration of abstract final int foo; It's an instance variable declaration, but it doesn't introduce any implementation.
Should probably only be generative constructors. Having an interface with factory constructors creating instances of classes implementing the interface, is a common pattern.
Can be combined with first item into:
Can only happen inside the same library.
Should have no effect if there is no generative constructor, and required if there is any abstract instance member (what must be abstract, so any instance member at all.)
Redundant with not allowing generative constructors and being abstract. Might also want:
Otherwise the interface can inherit concrete instance members. |
This comment was marked as resolved.
This comment was marked as resolved.
I have updated the proposal to account for @lrhn's feedback. |
Description
Warn when using interfaces in an impure way.
Details
Dart allows you to to use interfaces in an impure way (especially within the same library it is defined). This lint would detect and warn against any of the following in an interface:
a. Non-abstract interfaces
b. Non-abstract properties
c. Non-abstract methods
extends
orwith
extends
on an interfaceKind
Style advice
Bad Examples
Good Examples
Discussion
See also dart-lang/language#3736 and dart-lang/sdk#55641.
The text was updated successfully, but these errors were encountered: