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

Avoid warnings about unused values #1525

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

som-snytt
Copy link

@som-snytt som-snytt commented Jun 6, 2023

Noticed at https://discord.com/channels/632150470000902164/632150470000902166/1115280559023861800

This commit experiments with turning on lints, which helps test the following lintable changes.

The case is explicitly () to avoid inferring a LUB of Any or AnyVal for the match, since that value is unused. The actual LUB is Unit, which naturally never warns.

Two expressions are annotated nowarn because they are not consumed.

One change is for builder's mutating method to return this.type, which means it doesn't quality as an unconsumed value. skipField from Java API is ascribed : Unit to fix the inferred type of the match (which was Any or AnyVal) and also indicate that discarding the value was intentional (though Java results don't qualify as unconsumed).

Scala 3 doesn't like using a companion as a function unless it extends function. It is also safe to be explicit in Scala 2.

Two lints are turned off in test because of ScalaTest style.

MiMA exclusions are added for the this.type change, but that could be handled also as : Unit @nowarn at use site.

@som-snytt som-snytt marked this pull request as ready for review June 6, 2023 16:28
@som-snytt
Copy link
Author

Usually, I wait for test feedback before undrafting. Especially because I don't entirely know what I'm doing here.

@thesamet
Copy link
Contributor

Hi @som-snytt , checking in if you'd like to continue working on this PR?

@som-snytt
Copy link
Author

som-snytt commented Jun 19, 2023

Thanks, I've been reducing my personal backlog and this was still on it. I refreshed my unreliable memory and improved the tweaks. I think I didn't get the warnings right on 2.12, so that will require a fix. I can squash when it looks OK. (Edit: Needed to regenerate files.)

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

Successfully merging this pull request may close these issues.

None yet

2 participants