Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

クローズ
#112 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java
領域
tooling

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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 >.

主要言語
Java
スター
1
フォーク
1
平均マージ
2時間 22分
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CodeLaser/maddi のほかの issue

CodeLaser/maddi の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。