Avoid warnings about unused values #1525
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofAny
orAnyVal
for the match, since that value is unused. The actual LUB isUnit
, which naturally never warns.Two expressions are annotated
nowarn
because they are not consumed.One change is for builder's mutating method to returnthis.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 thethis.type
change, but that could be handled also as: Unit @nowarn
at use site.