From 928ec54a42e27b513611ffdff41ee166a6ffae22 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 14:52:37 +0000 Subject: [PATCH] fix: add generic type erasure fallback in stripGeneric + update scope-resolver docs Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/223f77ac-59a7-4487-9316-f2be05eac5d3 Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com> --- .../ingestion/languages/java/interpret.ts | 20 +++++++++++++++++-- .../languages/java/scope-resolver.ts | 11 ++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/gitnexus/src/core/ingestion/languages/java/interpret.ts b/gitnexus/src/core/ingestion/languages/java/interpret.ts index 107b879cd..19a6990c9 100644 --- a/gitnexus/src/core/ingestion/languages/java/interpret.ts +++ b/gitnexus/src/core/ingestion/languages/java/interpret.ts @@ -93,8 +93,18 @@ export function interpretJavaTypeBinding(captures: CaptureMatch): ParsedTypeBind } /** - * Unwrap a single-arg generic collection wrapper — `List`, - * `ArrayList`, `Optional` — to its element type. + * Unwrap generic type parameters from Java types. + * + * Three tiers, checked in order: + * 1. Known single-arg collection wrappers → extract the element type + * (`List` → `User`, `Optional` → `User`). + * 2. Known two-arg map/container types → extract the value type + * (`Map` → `User`). + * 3. **Fallback (JVM type erasure):** any other generic type → + * strip the generic parameters and keep the raw class name + * (`BaseModel` → `BaseModel`, `CustomList` → `CustomList`). + * This ensures receiver bindings (`this`/`super`) on classes with + * generic superclasses resolve to the correct class file. */ function stripGeneric(text: string): string { // Single-type-argument containers — extract the element type. @@ -109,6 +119,12 @@ function stripGeneric(text: string): string { ); if (twoArg !== null) return twoArg[1].trim(); + // Fallback: strip generic parameters from any unrecognized generic type. + // `BaseModel` → `BaseModel`, `Builder` → `Builder`. + // This mirrors JVM type erasure — the raw class name is the resolvable symbol. + const fallback = text.match(/^([A-Za-z_][A-Za-z0-9_.]*)<.+>$/); + if (fallback !== null) return fallback[1].trim(); + return text; } diff --git a/gitnexus/src/core/ingestion/languages/java/scope-resolver.ts b/gitnexus/src/core/ingestion/languages/java/scope-resolver.ts index 44533f347..bc7b937e5 100644 --- a/gitnexus/src/core/ingestion/languages/java/scope-resolver.ts +++ b/gitnexus/src/core/ingestion/languages/java/scope-resolver.ts @@ -21,8 +21,13 @@ * the parity CI workflow (`ci-scope-parity.yml`) does not run Java in * either `REGISTRY_PRIMARY_JAVA=0` or `=1` mode. Regressions in forced * mode are only visible via manual `REGISTRY_PRIMARY_JAVA=1 npx vitest - * run java.test.ts`. A tracking issue should be opened to monitor the - * 29-failure baseline and add a non-required CI step before flip. + * run java.test.ts`. Before flipping Java to registry-primary, a + * non-required CI step should be added to run Java tests in forced mode + * and report parity as a dashboard input. + * + * **Parity baseline (29 failures):** The 29 gaps in forced registry mode + * are tracked in the PR description and this JSDoc. If the gap count + * changes (up or down), update this baseline accordingly. * * ### Known flip-blockers (must fix before adding to MIGRATED_LANGUAGES) * @@ -31,6 +36,8 @@ * - Static import resolution: `import static X.Y.m` now correctly * resolves to `X/Y.java` (the class), not `X/Y/m.java` (the member). * Edge cases with nested classes may remain. + * - Generic superclass receiver binding: `BaseModel` now strips + * to `BaseModel` via JVM type-erasure fallback in `stripGeneric`. */ import type { ParsedFile } from 'gitnexus-shared';