-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Unused private constructor doesn't trigger unused_* #49654
Comments
Interestingly enough, adding a factory constructor starts triggering: void example(PublicClassPrivateConstructor? e) {
print(e == null);
}
class PublicClassPrivateConstructor {
factory PublicClassPrivateConstructor() {
throw UnimplementedError();
}
PublicClassPrivateConstructor._();
} |
Yeah it's intentional for the reasons you give. |
Want to change this to a request for |
I'll keep this open as we should change the behavior soon for Dart 3.0 |
It's not just a hint, it prevents the class from having an implicit public default constructor. |
Alright let's call it meaningful then. |
I have an inverse read of the situation, now that we have |
While I see your perspective, the code serves a purpose. There's another (and maybe better) way to accomplish the same purpose, but that doesn't negate the fact that the code can't just be removed without making other changes. The two styles are both valid Dart, and if would be irritating to a user that preferred the constructor approach to have diagnostics that they never intended to resolve. I could argue that the lint ought to flag such a constructor if the class is already marked as In addition, we could have a lint to flag cases where a class could be marked with Or we could skip the lint and implement an assist that would convert the class and remove the constructor. It isn't clear to me that anyone would discover such an assist, however. |
If you can guarantee that the default constructor of an |
Minimal reproduction:
I'm guessing there is an argument this is often a "hint" to prevent
extends
orwith
, which leads me to believe we need an@interface
annotation - but it's also probably reasonable to use// ignore: unused_constructor
for this purpose as well.The text was updated successfully, but these errors were encountered: