Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Geschlossen
#133 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Ein zugehöriger Pull Request wurde bereits gemerged.

  • #138 von @cowtowncoder — gemerged

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
java
Bereich
devtools

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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).

Vorherrschende Sprache
Java
Sterne
266
Forks
53
Ø Merge
18 Std. 46 Min.
Gemergte PRs (30 T.)
8

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus FasterXML/java-classmate

Alle Issues in FasterXML/java-classmate

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.