Member type of bare type variable bound to self-reference is`ResolvedRecursiveType` (unlike `T[]` or `List<T>`)
関連するプルリクエストがすでにマージされています。
- #138 @cowtowncoder による — マージ済み
評価
調査の方向性
Start with TypeResolver.resolve(TypeBindings, Type) and its _completeType() helper, then compare with resolveSubtype(), which already uses _selfReferenceTarget(). Use MemberResolver and the reproduction's Sym/Base classes to see why the field value keeps a ResolvedRecursiveType while arr does not. Done when value resolves to a fully resolved type equal to the arr element type, and the existing tests still pass.
索引モデルが issue の本文から書いたものです。
説明
When a member's type is a bare type variable bound to a self-reference, the resolved member type is a ResolvedRecursiveType (whose getParentClass() is null and getImplementedInterfaces() empty), whereas uses of the same variable within other types (T[], List<T>) resolve to fully resolved types.
Reproduction
public static class Base<X> { public X value; public X[] arr; }
public static class Sym<T extends Sym<T>> extends Base<T> { }
TypeResolver r = new TypeResolver();
ResolvedTypeWithMembers sym = new MemberResolver(r).resolve(r.resolve(Sym.class), null, null);
// field `value`: ResolvedRecursiveType `Sym<Object>`, getParentClass() == null
// field `arr`: element type is ResolvedObjectType `Sym<Sym<Object>>`
// -> value type not equal to `arr` element type
Same happens with raw self-references, like field X value of RB for RA<T extends RB> / RB extends Base<RA>.
On 1.7 / current main both value and arr element types are ResolvedRecursiveTypes (so they are at least consistent); with 1.8 (#128) incomplete types are re-resolved when obtained via TypeResolver.resolve(TypeBindings, Type) (as done by MemberResolver), except for bare self-references, which are left as-is.
Expected
Member type for value is a stand-alone (fully resolved) type, same as arr element type, so that member types can be navigated (parent class, interfaces) and compared consistently.
Notes
Likely fix: in TypeResolver.resolve(TypeBindings, Type) (_completeType()), replace a top-level self-reference with the type it represents (_selfReferenceTarget(), as resolveSubtype() already does). This changes member types that are currently ResolvedRecursiveTypes, so it is a behavioral change (although equality with fully resolved types is retained).
- 主要言語
- Java
- スター
- 266
- フォーク
- 53
- 平均マージ
- 18時間 46分
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
FasterXML/java-classmate のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
FasterXML/java-classmate#111 · コメント 10 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
FasterXML/java-classmate#81 · コメント 1 件 ·
-
Make `GenericType<T>` not implement `java.lang.reflect.Type`対応中かも @cowtowncoder が 311 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
FasterXML/java-classmate#76 · コメント 6 件 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
FasterXML/java-classmate#72 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
FasterXML/java-classmate#69 · コメント 22 件 ·
FasterXML/java-classmate の issue をすべて見る
似ている issue
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
quelea-projection/Quelea#711 ·
-
bug pdd
難易度 2/5 1時間未満 初心者へのやさしさ 67/100
objectionary/eo#9450 ·
メンテナーはふだん 1 日以内に返信
-
[EC2] DescribeAvailabilityZones should return real AWS error for unknown zone name対応中かも @omatheusmesmo が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
area: core good first issue type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100