maddi-java-openjdk: type-use annotations dropped from a nested class's field typed by the enclosing generic class
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- compilers, devtools, testing-qa
調査の方向性
Start with the reduced case exercised through JavaInspectorImpl as TestNullabilityPass, then trace how nested-class field types are represented in FieldInfo.type(). Compare the enclosing-class, nested-library-type, and enclosing-generic-type cases, and inspect where ParameterizedType type-use annotations are copied or lost. Done means AS<@Nullable Object> retains the annotation for the nested Holder field and the Kotlin translation no longer produces the nullability mismatch.
索引モデルが issue の本文から書いたものです。
説明
In a static nested class, a field whose type is the enclosing generic class loses the type-use annotations on its type arguments. guava's Ordering:
public abstract class Ordering<T> implements Comparator<T> {
private static final class ArbitraryOrderingHolder {
static final Ordering<@Nullable Object> ARBITRARY_ORDERING = new ArbitraryOrdering();
}
...
}
ARBITRARY_ORDERING's FieldInfo.type() arrives as Ordering<Object>, and the type argument's annotations() is empty.
Reduced, through JavaInspectorImpl as TestNullabilityPass in maddi-mod runs it:
package a.b;
import java.util.Comparator;
@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) @interface Nullable {}
abstract class AS<T> implements Comparator<T> {
static final AS<@Nullable Object> ARBITRARY = new Arbitrary(); // AS<@Nullable Object> (kept)
static AS<@Nullable Object> plain; // AS<@Nullable Object> (kept)
private static final class Holder {
static final AS<@Nullable Object> ARBITRARY = new Arbitrary(); // AS<Object> (dropped)
}
static class Arbitrary extends AS<@Nullable Object> {
public int compare(@Nullable Object a, @Nullable Object b) { return 0; }
}
}
The same annotation is kept on:
- a field of the outer class itself;
- a field of the nested class typed by a library class, e.g.
Comparator<@Nullable Object>inHolder.
The annotation is not needed on the @interface either: a top-level annotation type and one nested in AS give the same result.
Effect: the Kotlin translation prints internal val ARBITRARY_ORDERING: Ordering<Any> = ArbitraryOrdering(), while arbitrary(): Ordering<Any?> returns it. kotlinc reports "type mismatch: expected Ordering<Any?>, actual Ordering" (guava Ordering.kt:214).
Expected: the field's ParameterizedType carries the type-use annotations as written, as it does for the outer class's own fields.
Found while reducing guava's KotlinConf scoreboard compile errors, together with the printer session. Related: #144 (anonymous class creation types).
🤖 Generated with Claude Code
- 主要言語
- Java
- スター
- 1
- フォーク
- 1
- 平均マージ
- 1時間 58分
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CodeLaser/maddi のほかの issue
-
build/ci good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
C# printer: a self-bounded interface's wildcard interface and companion class share a name (CS0102)オープンfront-end:csharp
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
CodeLaser/maddi#160 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
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
メンテナーはふだん 1 日以内に返信
CodeLaser/maddi の issue をすべて見る
似ている issue
-
human-required sync-failed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Azure/osdu-spi-file#63 ·
メンテナーはふだん 1 日以内に返信
-
frontend quick win
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
CodeForPhilly/benefit-decision-toolkit#571 ·
メンテナーはふだん 1 日以内に返信
-
approved
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
checkstyle/checkstyle#22129 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Add Hardcharger JDBC driver対応中かも @prmoore77 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信