Lambda parameter type: a captured wildcard loses its bound (List<? extends >)
まだ誰も着手していません。
評価
調査の方向性
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 の本文から書いたものです。
説明
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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CodeLaser/maddi のほかの issue
-
build/ci good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
C# printer: an inner class of a generic class needs the outer type's arguments (Outer<A>.Inner)オープンfront-end:csharp
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
-
Java → C# translation: an idiomatic C# printer driven by the modification and nullability analysesオープンenhancement extension front-end:csharp
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
-
enhancement extension front-end:csharp
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
CodeLaser/maddi の issue をすべて見る
似ている issue
-
StepExamBenchmarkTest runs a loop and prints a timing but asserts nothing対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンjules
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
open-learning-exchange/myplanet#18199 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
Scheme-less stream URLs throw NullPointerException instead of URISyntaxException対応中かも @blihio が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pedroSG94/RootEncoder#2218 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/rocketmq-dashboard#6872 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ADORSYS-GIS/token-status-link#168 ·
メンテナーはふだん 2 日以内に返信