Annotate the rest of the main package (basically just the Java 8 subjects) for nullness. #1321
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.
Annotate the rest of the main package (basically just the Java 8 subjects) for nullness.
And move the
@NullMarked
annotation from individual classes up to the package.Motivation:
@NullMarked
to the package is about saving Truth users from a warning when running Error Prone with--release 8
: When@NullMarked
appears on a class, Error Prone processes the entireNullMarked
class in order to check whetherNullMarked
is@Inherited
. This leads towarning: unknown enum constant ElementType.MODULE
becauseNullMarked
has@Target(MODULE, ...)
butMODULE
isn't available until Java 9. We'll also be fixing this on the Error Prone side, but we might as well work around it on the Truth side, too—and annotate the rest of Truth while we're at it.(In principle, I should now add
@NullUnmarked
to all of Truth's test classes, since they haven't been annotated. But doing so would have little to no effect in practice unless maybe IntelliJ recognizes@NullUnmarked
(probably not now?) or we improve our nullness offerings in Error Prone. I'm planning to not bother, but let me know if I'm being overly lazy.)Note that this CL applies
@Nullable
to some assertion methods' parameters even though those assertions would always fail if the callers passednull
. This follows a principle that we'd applied (albeit incompletely) in cl/516515683, which showed that such changes avoided producing build errors in existing, working code. The principle is the same as that discussed forEqualsTester
in cl/578260904.Fixes #1320
RELNOTES=Annotated the rest of the main package for nullness, and moved the
@NullMarked
annotation from individual classes up to the package to avoid a warning under--release 8
.