Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
42708ad
Resolve an inference variable that a type variable admitting null rea…
vlsi Oct 10, 2026
aa64a9c
Keep an inferred type variable only where its bound admits null
vlsi Nov 24, 2026
8b21c56
Link the known gaps in the new tests to their issues
vlsi Nov 24, 2026
1e64052
Report a captured nullable-bound argument and name the declaring element
vlsi Nov 24, 2026
cdb98d4
Report a wildcard argument only where its type parameter admits null
vlsi Nov 24, 2026
d90c0e9
Check only a bare type variable passed for a non-null `? extends U`
vlsi Nov 25, 2026
93031bc
Decide parametric nullness of a capture by one predicate
vlsi Nov 25, 2026
79f0d24
Run nullable-bound inference only with JSpecifyExperimental
vlsi Nov 26, 2026
648f1cf
Describe the inferred-nullness steps precisely in Javadoc
vlsi Nov 26, 2026
8f83a0a
Build Calcite at a commit that includes apache/calcite#5454
vlsi Nov 26, 2026
c5dd5da
Accept a capture-typed value where the same capture is expected
vlsi Nov 26, 2026
15438ba
Name which capture accepts a NO_CHANGE value; test the ? super T boun…
vlsi Nov 26, 2026
7c91629
Carry nullness across a declared bound between inference variables
vlsi Nov 26, 2026
79aa1c4
Keep null-unmarked bounds out of the declared-bound edge
vlsi Nov 26, 2026
c760074
Test the library-model and nested cases of declared-bound edges
vlsi Nov 26, 2026
5d871fe
Name every ? super target that accepts a NO_CHANGE value; test the ga…
vlsi Nov 26, 2026
a0fa921
Link the nested-bound false negative to #2192
vlsi Nov 26, 2026
d0ad3f0
Drop the bound-nullability memo from the constraint solver
vlsi Nov 26, 2026
145d3ed
State the declared-bound edge rule once, with its chain closure
vlsi Nov 26, 2026
6ba4798
Report a generic nullability mismatch as a marked diff of the two types
vlsi Sep 9, 2026
e4d367a
Group the mismatch message tests by the part of the message they check
vlsi Oct 12, 2026
3271f4e
Offer the required type where one type instance fills two type arguments
vlsi Oct 12, 2026
f847fe1
Stop the mismatch traversal at a bound comparison already in progress
vlsi Nov 27, 2026
abad664
Adapt the mismatch message to master without #1834
vlsi Nov 27, 2026
bb1e444
Report a type variable whose bound admits null where a non-null wildc…
vlsi Nov 26, 2026
c357279
Explain a type variable whose bound admits null instead of falling back
vlsi Sep 9, 2026
6860631
Check the #1834 tests against the mismatch message
vlsi Nov 27, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
- project: calcite
url: https://github.com/apache/calcite.git
branch: main
sha: 713faf069e246f3430ae23ead1f90430c672cc15
sha: dde58eb5a30f245f975d55f88ce2e861a1e82668
build: JAVA_HOME="$JAVA_HOME_21_X64" ./gradlew --init-script use-snapshot.gradle.kts -PenableErrorprone classes jmhClasses
permissions:
contents: read
Expand Down
32 changes: 32 additions & 0 deletions nullaway/src/main/java/com/uber/nullaway/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,38 @@ public interface Config {
/** Should PolyNull library models be enabled? */
boolean isPolyNullLibraryModelsEnabled();

/**
* Should generic inference account for the nullness of an unannotated type variable, a capture
* included, whose bound admits null, and read a declared bound {@code U extends R} between two
* type variables of a call as {@code U <: R}? True where both JSpecifyMode and
* JSpecifyExperimental are set. Where it is false, every inference variable that no constraint
* fixes is {@code @NonNull}, and the checks of a generic constructor at a diamond and of a
* generic method reference use the declared types.
*
* <p>Where it is true, an inference variable that no constraint fixes and that such a type
* variable flows into is {@link
* com.uber.nullaway.generics.ConstraintSolver.InferredNullability#TYPE_VARIABLE_OR_NULLABLE}
* where the bounds of both that type variable and the inference variable are explicitly nullable,
* and {@link
* com.uber.nullaway.generics.ConstraintSolver.InferredNullability#TYPE_VARIABLE_OR_NONNULL}
* otherwise. {@code GenericsUtils.typeVariableWithNullableBound} decides which bounds are
* explicitly nullable. With HandleWildcardGenerics also set, inference fails where an uncaptured
* type variable whose bound is explicitly nullable is passed for {@code ? extends U} and the
* bound of {@code U} excludes null. A generic constructor at a diamond and a generic method
* reference are checked against the types javac inferred for them.
*
* <p>Where it is true, inference also reads a declared bound {@code U extends R} between two type
* variables of one call, where the use of {@code R} carries no nullness annotation, as {@code U
* <: R}, and follows a chain of such bounds. {@code @Nullable} and the flow of an unannotated
* type variable whose bound admits null pass from {@code U} to {@code R}, and {@code @NonNull}
* passes from {@code R} to {@code U}. So {@code viaBoundOne(null).hashCode()} with {@code <R
* extends @Nullable Object, U extends R> R viaBoundOne(U u)} is reported, though no type variable
* whose bound admits null is passed. Inference reads no {@code U <: R} where the declaration of
* {@code U} makes its bound nullable: where a library model does so, or where {@code U} is
* declared in unannotated code.
*/
boolean isNullableBoundInferenceEnabled();

/**
* Should wildcard-aware generic nullability checks be enabled? These also compute {@link
* Nullness#NO_CHANGE} for the values listed there, such as the result of {@code Box<? extends
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ public boolean isPolyNullLibraryModelsEnabled() {
throw new IllegalStateException(ERROR_MESSAGE);
}

@Override
public boolean isNullableBoundInferenceEnabled() {
throw new IllegalStateException(ERROR_MESSAGE);
}

@Override
public boolean handleWildcardGenerics() {
throw new IllegalStateException(ERROR_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ final class ErrorProneCLIFlagsConfig implements Config {
private final boolean acknowledgeAndroidRecent;
private final boolean jspecifyMode;
private final boolean polyNullLibraryModelsEnabled;
private final boolean nullableBoundInferenceEnabled;
private final boolean handleWildcardGenerics;
private final boolean warnOnInferenceFailure;
private final ImmutableSet<MethodClassAndName> knownInitializers;
Expand Down Expand Up @@ -311,6 +312,7 @@ final class ErrorProneCLIFlagsConfig implements Config {
acknowledgeAndroidRecent = flags.getBoolean(FL_ACKNOWLEDGE_ANDROID_RECENT).orElse(false);
jspecifyMode = flags.getBoolean(FL_JSPECIFY_MODE).orElse(false);
polyNullLibraryModelsEnabled = jspecifyMode && jspecifyExperimental;
nullableBoundInferenceEnabled = jspecifyMode && jspecifyExperimental;
handleWildcardGenerics =
flags.getBoolean(FL_HANDLE_WILDCARD_GENERICS).orElse(jspecifyExperimental);
assertsEnabled = flags.getBoolean(FL_ASSERTS_ENABLED).orElse(false);
Expand Down Expand Up @@ -624,6 +626,11 @@ public boolean isPolyNullLibraryModelsEnabled() {
return polyNullLibraryModelsEnabled;
}

@Override
public boolean isNullableBoundInferenceEnabled() {
return nullableBoundInferenceEnabled;
}

@Override
public boolean handleWildcardGenerics() {
return handleWildcardGenerics;
Expand Down
6 changes: 4 additions & 2 deletions nullaway/src/main/java/com/uber/nullaway/Nullness.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ public enum Nullness implements AbstractValue<Nullness> {
*
* <p>A dereference of the value is reported, since the value is not null-exclusive under every
* parameterization. An assignment, an argument, a return, or an array store accepts the value
* where nullness subtyping holds: where the target's type is {@code T}, or a capture of {@code ?
* super T}, without {@code @NonNull}, as {@link
* where nullness subtyping holds: where the target's type carries no {@code @NonNull} and is the
* value's own type (for example the capture of {@code ? extends T} that javac infers for a
* generic parameter), a type variable that the value's type reaches through non-nullable bounds
* (for example {@code T}), or a capture of {@code ? super} either of those types, as {@link
* com.uber.nullaway.generics.GenericsChecks#acceptsNoChangeValue} decides. At any other target
* the value is {@link #NULLABLE}, and so is a variable of another type that dataflow assigns it
* to. Generic method inference takes no nullness constraint from the value and infers {@code T}.
Expand Down
Loading
Loading