Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Lambda parameter type: a captured wildcard loses its bound (List<? extends >)

Chiusa
#112 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
tooling

Direzione di ricerca

Start from ParameterizedTypePrinter, which prints ? extends with nothing after it when the wildcard is EXTENDS and has neither a type parameter nor type info. Reproduce with the q.F snippet in the issue, then inspect lambda.methodInfo().parameters().getFirst().parameterizedType() for the inner lambda. Done when the printed type keeps the bound (List<? extends T>) and the output parses again. Check with the maintainers which denotable approximation they want before choosing one.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Problem

The type of an implicitly typed lambda parameter whose type involves a capture loses the capture's bound. ? extends T becomes ? extends with nothing after it, and prints as List<? extends >.

package q;
import java.util.List;
import java.util.function.Consumer;
public class F {
    interface Box<T> { void onComplete(Consumer<? super List<T>> c); }
    static <T> void find(List<Box<? extends T>> boxes) {
        boxes.forEach(box -> box.onComplete(result -> System.out.println(result.size())));
    }
}

For the inner lambda, lambda.methodInfo().parameters().getFirst().parameterizedType() is

java.util.List<? extends >

and lambda.concreteFunctionalType() is java.util.function.Consumer<java.util.List<? extends >>. In the model the wildcard is EXTENDS, with neither a type parameter nor a type info, so ParameterizedTypePrinter prints ? extends followed by nothing. The outer lambda's parameter is fine: q.F.Box<? extends T>.

Expected

javac types result as List<CAP#1>, where CAP#1 is the capture of ? extends T. A denotable approximation keeps the bound: List<? extends T>, and Consumer<List<? extends T>> for the functional type. At the very least the bound T should not be lost.

Why it matters

As long as the lambda stays a lambda, the parameter type is never printed. It is printed as soon as code is generated from it: a rewrite of the lambda into an anonymous class (new Consumer<List<? extends >>() { public void accept(List<? extends > result) ... }), a helper method that receives the value, or an explicitly typed lambda. The result does not parse ("illegal start of type").

Seen on

maddi 0.9.5-alpha.9. On real code: vavr io.vavr.concurrent.Future.find, list.forEach(future -> future.onComplete(result -> { ... })) with list a List<Future<? extends T>>. The parameter type comes out as io.vavr.control.Try<? extends >.

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
2h 22m
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeLaser/maddi

Tutte le issue di CodeLaser/maddi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.