Bad error message: `WarnOnGenericInferenceFailure` flags `Collector<_, ?, _>` arguments passed to `@NullMarked` methods such as Reactor's `Flux#collect`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
Direzione di ricerca
Start with the reproducer Repro1 and the WarnOnGenericInferenceFailure option, then compare with Stream#collect, which is not flagged. The open question is whether this is intended under the JSpecify unbounded-wildcard rule, so a maintainer decision comes before any code change. Done means that decision is recorded and, if the warning stays, its message names the wildcard rather than only @Nullable.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
(This bug report was generated by Claude Sonnet 5.5 with "high" effort. See also https://github.com/PicnicSupermarket/error-prone-support/pull/2299#issuecomment-6590316084.)
With JSpecifyExperimental, passing a collector with an unbounded-wildcard accumulator type (Collectors.toList(), Guava's toImmutableList(), ...) to a @NullMarked generic method whose accumulator type parameter A has no @Nullable bound reports an inference failure. No @Nullable appears in the source, and no @NullUnmarked code is involved: a real-world example is reactor.core.publisher.Flux#collect(Collector), which is declared <R, A> Mono<R> collect(Collector<? super T, A, ? extends R>) in a @NullMarked package (Reactor 3.8.8). This accounts for 9 of the 15 inference failures we see in our code base.
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import org.jspecify.annotations.NullMarked;
@NullMarked
class Repro1 {
static class Pipeline<T> {
<R, A> R collect(Collector<? super T, A, ? extends R> collector) {
throw new RuntimeException();
}
}
List<String> test(Pipeline<String> pipeline) {
return pipeline.collect(Collectors.toList());
}
}
Options: -XepOpt:NullAway:OnlyNullMarked=true -XepOpt:NullAway:JSpecifyMode=true -XepOpt:NullAway:JSpecifyExperimental=true
Repro1.java:15: warning: [NullAway] inference failure: type variable A is constrained to be @Nullable, but its upper bound requires it to be @NonNull
return pipeline.collect(Collectors.toList());
^
Reproduced with NullAway 0.14.3 and with master (002c08d2), Error Prone 2.51.0, JDK 25. No diagnostic is reported with -XepOpt:NullAway:WarnOnGenericInferenceFailure=false.
Observations:
Stream#collectis not flagged for the same collectors.- The JDK-free form
interface Box<A extends @Nullable Object>,static Box<?> box()andstatic <A> void take(Box<A> box)reproduces too (take(box())), whileBox<? extends Object>does not. - This may be working as specified: my reading of the JSpecify specification (section "Bound of an 'unbounded' wildcard") is that in null-marked code
?has an upper boundObjectwith aUNION_NULLnullness operator, irrespective of the declared bound, so its capture is not within a non-null bound. If so,Flux#collectarguably ought to declareA extends @Nullable Object. But as it flags everyFlux#collect(Collectors.xyz())call, I wonder whether this is intended to surface as a user-facing warning, or whether inference should accept the capture of an unbounded wildcard here. - The message mentions
@Nullable, though nothing nullable is in sight; it does not mention the wildcard.
- Lingua principale
- Java
- Stelle
- 4.1k
- Fork
- 381
- Merge medio
- 1g 2h
- PR unite (30g)
- 106
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di uber/NullAway
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
uber/NullAway#2145 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
uber/NullAway#2058 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
uber/NullAway#1899 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
uber/NullAway#2160 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di uber/NullAway
Issue simili
-
Cleanup: restore the interrupt flag in AiFailureAnalyzerForse già presa @Rishankgupta08 l’ha presa oggi. Apertagood first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
seleniumboot/selenium-boot#258 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
dense-analysis/ale#5181 ·
-
bug subsystem:agent-harness triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ShaftHQ/SHAFT_ENGINE#8043 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
johanhaleby/occurrent#1505 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno