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>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-11 14:52:37 +00:00 committed by GitHub
parent 81c84426bc
commit 928ec54a42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 4 deletions

View file

@ -93,8 +93,18 @@ export function interpretJavaTypeBinding(captures: CaptureMatch): ParsedTypeBind
}
/**
* Unwrap a single-arg generic collection wrapper `List<User>`,
* `ArrayList<User>`, `Optional<User>` 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>` `User`, `Optional<User>` `User`).
* 2. Known two-arg map/container types extract the value type
* (`Map<String, User>` `User`).
* 3. **Fallback (JVM type erasure):** any other generic type
* strip the generic parameters and keep the raw class name
* (`BaseModel<T>` `BaseModel`, `CustomList<Foo>` `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<T>` → `BaseModel`, `Builder<Self>` → `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;
}

View file

@ -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<T>` now strips
* to `BaseModel` via JVM type-erasure fallback in `stripGeneric`.
*/
import type { ParsedFile } from 'gitnexus-shared';