-
Couldn't load subscription status.
- Fork 1.1k
Improve -Wunused: locals, privates with unset vars warning #16639 #17160
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
Improve -Wunused: locals, privates with unset vars warning #16639 #17160
Conversation
|
I was sick the previous week 🤒 So sorry for the delay in reviewing @schuetzcarl But could you please rebase and fix conflicts in this PR? A lot changed in the CheckUnused when we were fixing the bugs for the new RC for 3.3.0 |
8713944 to
9facd95
Compare
9facd95 to
d4bd097
Compare
Hi Szymon, No problem, I hope you are fine now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone through it and almost everything seems great, I have only one comment.
| Nil | ||
| (Nil, Nil) | ||
| val sortedPrivateDefs = unusedPrivates.filterNot(d => containsSyntheticSuffix(d.symbol)).map(d => UnusedSymbol(d.namePos, d.name, WarnTypes.PrivateMembers)).toList | ||
| val unsetPrivateDefs = unsetVarsFromUsedSym(usedPrivates).map(d => UnusedSymbol(d.namePos, d.name, WarnTypes.UnsetPrivates)).toList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the function unsetVarsFromUsedSym to a boolean-returning isUnsetVar and using it with .filter would be easier to read, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review :)
I changed the unsetVarsFromUsedSym to an isUnsetVarDef helper function in the tpd.MemberDef extension object.
Let me know if it is convenient for you.
This PR is related to my Bachelor Semester Project, supervised by @anatoliykmetyuk.
The latter consist in improving and implementing more Scala 3 linter options (see #15503), with #16639 as a starting issue fixed in this PR.
Assigncase, symbols are collected as set, and then used to filter used locals and privates variable at reporting time.That feature follows the Scala 2
-Ywarn-unused:<args>behavior.