Skip to content
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

consider a lint to encourage use of super-initializers where possible #3174

Closed
Tracked by #3131
pq opened this issue Jan 24, 2022 · 1 comment · Fixed by #3265
Closed
Tracked by #3131

consider a lint to encourage use of super-initializers where possible #3174

pq opened this issue Jan 24, 2022 · 1 comment · Fixed by #3265

Comments

@pq
Copy link
Member

pq commented Jan 24, 2022

No description provided.

@bwilkerson
Copy link
Member

bwilkerson commented Jan 25, 2022

Just brainstorming, but I believe that the lint will need to verify that

  • the constructor is a generative constructor,
  • the parameter is passed to a super constructor,
  • either the parameter isn't referenced in the body of the constructor or there is a getter and/or setter with the same name (and we might want to drop the latter condition to avoid false positives),
  • the type of the parameter is a subtype of the type of the corresponding parameter in the super constructor,
  • if the super constructor invocation has any positional arguments then all of the positional arguments could be converted to be super initializer parameters, and
  • if the parameter has a default value then the default value matches the default value of the corresponding parameter.

There are probably more restrictions that I'm not thinking of that will be needed in order to prevent false positives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants