Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Member type of bare type variable bound to self-reference is`ResolvedRecursiveType` (unlike `T[]` or `List<T>`)

已关闭
#133 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

已经有一个关联 PR 被合并了。

  • #138 来自 @cowtowncoder —— 已合并

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
java
领域
devtools

调研方向

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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

FasterXML/java-classmate 的其他 Issue

查看 FasterXML/java-classmate 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。