Lambda parameter type: a captured wildcard loses its bound (List<? extends >)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
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
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
- 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 CodeLaser/maddi
-
:maddi-inspection-kotlin:test runs out of heap in a full maddi test run; exit 1 with no failing testApertabuild/ci front-end:kotlin
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
build/ci good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug front-end:javac
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 49/100
Tutte le issue di CodeLaser/maddi
Issue simili
-
agent-java community triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elastic/apm-agent-java#4594 ·
I maintainer di solito rispondono entro 1 giorno
-
area/plugin good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
kestra-io/plugin-soda#137 ·
-
area/plugin good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
kestra-io/plugin-aws#816 ·
I maintainer di solito rispondono entro 2 giorni
-
area/plugin good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
kestra-io/plugin-kestra#200 ·
I maintainer di solito rispondono entro 1 giorno
-
bug untriaged
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
opensearch-project/search-relevance#618 ·
I maintainer di solito rispondono entro 3 giorni