You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Indicate when an inference failure is due to a @NonNull type variable upper bound #1721
16 errors read "inference failure: type variable V constrained to be both @nonnull and @nullable",
concentrated in generic inference and wildcards. These were Caffeine's fault, not NullAway's. CompletableFuture<T extends @Nullable Object> and BiFunction<T, U, R> with all three bounded by @Nullable Object; Caffeine's helpers declared plain type variables, which bind to non-null Object in null-marked code, so they could not accept those types at all. Widening the bounds
cleared all 16.
The diagnostic could point at this more directly. Adding an explicit type witness produces the
message that actually explains it:
Type argument cannot be @Nullable, as method <T,U,R>identity(...)'s type variable U is not @Nullable
whereas the inferred call says only that a type variable is "constrained to be both @nonnull and @nullable", which reads like an inference defect rather than a missing bound on the user's own
declaration.
changed the title [-]Inscrutable error messages from inference failures[/-][+]Indicate when an inference failure is due to a `@NonNull` type variable upper bound[/+]on Aug 28, 2026
I scoped this one down to making the error message indicate more clearly when an inference failure is due to a @NonNull upper bound on a type variable. We could improve inference failure methods in various other ways, but that will require deeper investigation and design work.
Activity
[-]Inscrutable error messages from inference failures[/-][+]Indicate when an inference failure is due to a `@NonNull` type variable upper bound[/+]msridhar commentedon Aug 28, 2026
I scoped this one down to making the error message indicate more clearly when an inference failure is due to a
@NonNullupper bound on a type variable. We could improve inference failure methods in various other ways, but that will require deeper investigation and design work.Improve diagnostics for non-null type variable bounds
Improve diagnostics for non-null type variable bounds
Improve diagnostics for non-null type variable bounds
Improve diagnostics for non-null type variable bounds (apache#1770)