mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-23 00:41:36 +00:00
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:
parent
81c84426bc
commit
928ec54a42
2 changed files with 27 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue