diff --git a/gitnexus/test/fixtures/lang-resolution/java-variadic-resolution/com/example/app/Main.java b/gitnexus/test/fixtures/lang-resolution/java-variadic-resolution/com/example/app/Main.java index fea40d97f..88c3b71ac 100644 --- a/gitnexus/test/fixtures/lang-resolution/java-variadic-resolution/com/example/app/Main.java +++ b/gitnexus/test/fixtures/lang-resolution/java-variadic-resolution/com/example/app/Main.java @@ -14,5 +14,12 @@ public class Main { // 3-arg call: satisfies fixed prefix (level) + 2 varargs fmt.format(2, "hello", "world"); } + + public void badCall() { + Formatter fmt = new Formatter(); + // 0-arg call: does NOT satisfy the required fixed prefix (int level) + // This should be rejected by arity — no CALLS edge to format + fmt.format(); + } } diff --git a/gitnexus/test/integration/resolvers/java.test.ts b/gitnexus/test/integration/resolvers/java.test.ts index c5cd91e0b..a02a7e8a5 100644 --- a/gitnexus/test/integration/resolvers/java.test.ts +++ b/gitnexus/test/integration/resolvers/java.test.ts @@ -444,11 +444,23 @@ describe('Java variadic call resolution', () => { it('resolves 2-arg call to fixed-prefix varargs method format(int, String...) in Formatter.java', () => { const calls = getRelationships(result, 'CALLS'); - const fmtCall = calls.find((c) => c.target === 'format'); + const fmtCall = calls.find((c) => c.target === 'format' && c.source === 'run'); expect(fmtCall).toBeDefined(); - expect(fmtCall!.source).toBe('run'); expect(fmtCall!.targetFilePath).toBe('com/example/util/Formatter.java'); }); + + it('0-arg call to format(int, String...) still resolves in legacy mode (arity rejection is registry-only)', () => { + // In REGISTRY_PRIMARY_JAVA=1 mode, `requiredParameterCount = 1` causes + // `javaArityCompatibility` to return 'incompatible' for 0-arg calls, + // preventing the CALLS edge. In default (legacy) mode, arity is not + // enforced so the edge is created. This test documents the legacy + // behavior; the negative assertion is a flip-blocker for registry-primary. + const calls = getRelationships(result, 'CALLS'); + const zeroArgFmtCall = calls.find( + (c) => c.target === 'format' && c.source === 'badCall', + ); + expect(zeroArgFmtCall).toBeDefined(); + }); }); // --------------------------------------------------------------------------- @@ -477,6 +489,7 @@ describe('Java wildcard import resolution', () => { const calls = getRelationships(result, 'CALLS'); const saveCall = calls.find((c) => c.target === 'save' && c.source === 'run'); expect(saveCall).toBeDefined(); + expect(saveCall!.targetFilePath).toBe('com/example/models/User.java'); }); });