Member type of bare type variable bound to self-reference is`ResolvedRecursiveType` (unlike `T[]` or `List<T>`)
已经有一个关联 PR 被合并了。
- #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 分钟
- 30 天内合并 PR
- 8
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
FasterXML/java-classmate 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
FasterXML/java-classmate#111 · 10 条评论 ·
-
难度 5/5 一周以上 新手友好度 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 个 reaction ·
-
难度 5/5 一周以上 新手友好度 20/100
FasterXML/java-classmate#72 · 3 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
FasterXML/java-classmate#69 · 22 条评论 ·
查看 FasterXML/java-classmate 的全部 Issue
相似的 Issue
-
Flight SQL JDBC parses boolean properties case-sensitively, silently disabling TLS for useEncryption=TRUE可能已有人在做 @Arawoof06 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
apache/arrow-java#1357 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
apache/rocketmq-dashboard#6610 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
MetricsHub/metricshub-community#1396 ·
维护者通常 1 天内回复
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
难度 2/5 1-3 小时 新手友好度 76/100
dependabot/dependabot-core#16547 ·
维护者通常 1 天内回复
-
Citationcount column sorts alphabetically instead of numerically可能已有人在做 @kpunia306 今天认领。 未关闭status: needs-triage
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复