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

Add @Nullable to the bound of Supplier. #5446

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions android/guava/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion android/guava/src/com/google/common/base/Supplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* A class that can supply objects of a single type; a pre-Java-8 version of {@link
Expand Down Expand Up @@ -45,7 +46,7 @@
* @since 2.0
*/
@GwtCompatible
public interface Supplier<T> {
public interface Supplier<T extends @Nullable Object> {
/**
* Retrieves an instance of the appropriate type. The returned object may or may not be a new
* instance, depending on the implementation.
Expand Down
13 changes: 13 additions & 0 deletions android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<!-- Override this with -Dtest.include="**/SomeTest.java" on the CLI -->
<test.include>%regex[.*.class]</test.include>
<truth.version>1.1</truth.version>
<checker-framework.version>3.8.0</checker-framework.version>
<!--
Upgrading to 1.19 breaks things: Animal Sniffer reports a problem with the
use of ClassValue in FuturesGetChecked, even though we've added a
Expand Down Expand Up @@ -275,6 +276,18 @@
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>${checker-framework.version}</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>${checker-framework.version}</version>
<classifier>sources</classifier>
</dependency>
<!-- TODO(cpovirk): Remove checker-compat-qual after we finish migrating to type annotations. -->
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
Expand Down
15 changes: 15 additions & 0 deletions guava-gwt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<classifier>sources</classifier>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -129,6 +134,8 @@
<!-- 2. Don't include the source in the jar (since that would let users depend on it from GWT client code, which is compiled from source). -->
<exclude>**/ForceGuavaCompilation*</exclude>
<exclude>**/DummyJavadocClass*</exclude>
<!-- (unrelated interruption: Also don't include our fabricated CF GWT module descriptor. -->
<exclude>**/Qual.gwt.xml</exclude>
</excludes>
</configuration>
</plugin>
Expand All @@ -139,6 +146,8 @@
<!-- 3. Don't include it in the source jar (since it's really more of a "test" than it is production code). -->
<exclude>**/ForceGuavaCompilation*</exclude>
<exclude>**/DummyJavadocClass*</exclude>
<!-- (unrelated interruption: Also don't include our fabricated CF GWT module descriptor. I don't think anyone should be using our *sources* jar, anyway, at least not as an input to GWT compilation, but it seems safest to exclude here, just as we do for maven-jar-plugin, to be safe. -->
<exclude>**/Qual.gwt.xml</exclude>
</excludes>
</configuration>
</plugin>
Expand Down Expand Up @@ -299,6 +308,12 @@
<include name="**/InternalFutureFailureAccess.java" />
</fileset>
</copy>
<!-- We fabricate a GWT module to cover the CF annotations. Then we inherit it in ForceGuavaCompilation.gwt.xml. -->
<echo file="${project.build.directory}/guava-gwt-sources/org/checkerframework/checker/nullness/qual/Qual.gwt.xml">
&lt;module&gt;&lt;source path="" /&gt;&lt;/module&gt;
</echo>
<!-- TODO(cpovirk): DO NOT RELEASE in this state: I suspect that downstream users of guava-gwt will see their compilation fail from the "missing" CF annotations (whether because those sources are missing entirely or because they're present but without a module descriptor). -->
<!-- In contrast to what we do with our *own* sources (i.e., those from guava, guava-testlib, and guava-tests), we *don't* copy the CF annotations to guava-gwt-sources (and so we don't need to unpack them ourselves at all). If we did, they would end up in our generated jar. And we don't need to, anyway: The GWT plugin picks them up automatically because of the <classifier>source</classifier> dependency above. -->
<copy toDir="${project.build.directory}/guava-test-gwt-sources">
<fileset dir="${project.build.directory}/guava-test-sources">
<contains text="@GwtCompatible"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<inherits name="com.google.common.xml.Xml" />
<inherits name="com.google.thirdparty.publicsuffix.PublicSuffixPatterns" />
<inherits name="com.google.thirdparty.publicsuffix.PublicSuffixType" />
<inherits name="org.checkerframework.checker.nullness.qual.Qual" />

<!-- com.google.common.testing.Testing is located in
GuavaTests under guava-gwt/test -->
Expand Down
3 changes: 2 additions & 1 deletion guava/src/com/google/common/base/Supplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* Legacy version of {@link java.util.function.Supplier java.util.function.Supplier}. Semantically,
Expand All @@ -37,7 +38,7 @@
*/
@GwtCompatible
@FunctionalInterface
public interface Supplier<T> extends java.util.function.Supplier<T> {
public interface Supplier<T extends @Nullable Object> extends java.util.function.Supplier<T> {
/**
* Retrieves an instance of the appropriate type. The returned object may or may not be a new
* instance, depending on the implementation.
Expand Down
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<!-- Override this with -Dtest.include="**/SomeTest.java" on the CLI -->
<test.include>%regex[.*.class]</test.include>
<truth.version>1.1</truth.version>
<checker-framework.version>3.8.0</checker-framework.version>
<!--
Upgrading to 1.19 breaks things: Animal Sniffer reports a problem with the
use of ClassValue in FuturesGetChecked, even though we've added a
Expand Down Expand Up @@ -274,7 +275,13 @@
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>3.8.0</version>
<version>${checker-framework.version}</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>${checker-framework.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
Expand Down