Skip to content

Commit aff5719

Browse files
committed
fix: resolve merge conflicts with feat/prototype-resolver-1317 (round 2)
2 parents 16a4058 + 9fb1a8b commit aff5719

7 files changed

Lines changed: 333 additions & 68 deletions

File tree

src/domain/graph/builder/stages/native-orchestrator.ts

Lines changed: 283 additions & 22 deletions
Large diffs are not rendered by default.

src/domain/wasm-worker-entry.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,6 @@ function serializeExtractorOutput(
805805
dataflow: symbols.dataflow,
806806
astNodes,
807807
...(symbols.fnRefBindings?.length ? { fnRefBindings: symbols.fnRefBindings } : {}),
808-
...(symbols.paramBindings?.length ? { paramBindings: symbols.paramBindings } : {}),
809808
...(symbols.arrayElemBindings?.length ? { arrayElemBindings: symbols.arrayElemBindings } : {}),
810809
...(symbols.spreadArgBindings?.length ? { spreadArgBindings: symbols.spreadArgBindings } : {}),
811810
...(symbols.forOfBindings?.length ? { forOfBindings: symbols.forOfBindings } : {}),

src/domain/wasm-worker-pool.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ function deserializeResult(ser: SerializedExtractorOutput | null): ExtractorOutp
107107
// visitor output is cast the same way.
108108
if (ser.astNodes !== undefined) out.astNodes = ser.astNodes as unknown as ASTNodeRow[];
109109
if (ser.fnRefBindings?.length) out.fnRefBindings = ser.fnRefBindings;
110-
if (ser.paramBindings?.length) out.paramBindings = ser.paramBindings;
111110
if (ser.arrayElemBindings?.length) out.arrayElemBindings = ser.arrayElemBindings;
112111
if (ser.spreadArgBindings?.length) out.spreadArgBindings = ser.spreadArgBindings;
113112
if (ser.forOfBindings?.length) out.forOfBindings = ser.forOfBindings;

src/domain/wasm-worker-protocol.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import type {
1919
Export,
2020
Import,
2121
LanguageId,
22-
ParamBinding,
2322
TypeMapEntry,
2423
} from '../types.js';
2524

@@ -65,7 +64,6 @@ export interface SerializedExtractorOutput {
6564
receiver?: string;
6665
}>;
6766
fnRefBindings?: import('../types.js').FnRefBinding[];
68-
paramBindings?: ParamBinding[];
6967
arrayElemBindings?: import('../types.js').ArrayElemBinding[];
7068
spreadArgBindings?: import('../types.js').SpreadArgBinding[];
7169
forOfBindings?: import('../types.js').ForOfBinding[];

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,8 @@ export interface BuildResult {
12401240
edgesMs: number;
12411241
structureMs: number;
12421242
rolesMs: number;
1243+
/** Wall-clock time for the this/super dispatch WASM post-pass (native path only). */
1244+
thisDispatchMs?: number;
12431245
astMs: number;
12441246
complexityMs: number;
12451247
cfgMs: number;

tests/integration/phase-8.5-cha-dispatch.test.ts

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -119,53 +119,34 @@ describe.each(ENGINES)('Phase 8.5 CHA dispatch (%s)', (engine) => {
119119
});
120120

121121
// ── this-dispatch ──────────────────────────────────────────────────────
122-
// The WASM path resolves `this.prepare()` through the class hierarchy via
123-
// the inline CHA dispatch in buildFileCallEdges.
124-
//
125-
// The native orchestrator path does not persist raw call sites (with receiver
126-
// info) to the DB after the Rust pipeline runs, so this-dispatch and
127-
// super-dispatch cannot be resolved via runPostNativeCha.
128-
// Tracked as a native accuracy gap in issue #1326.
129122

130-
if (engine === 'native') {
131-
it.todo(
132-
'this-dispatch: emits ConcreteWorker.doWork → ConcreteWorker.prepare (native gap #1326)',
123+
it('this-dispatch: emits ConcreteWorker.doWork → ConcreteWorker.prepare', () => {
124+
const edge = callEdges.find(
125+
(e) =>
126+
e.caller_name === 'ConcreteWorker.doWork' &&
127+
e.callee_name === 'ConcreteWorker.prepare' &&
128+
e.callee_file === 'ConcreteWorker.ts',
133129
);
134-
} else {
135-
it('this-dispatch: emits ConcreteWorker.doWork → ConcreteWorker.prepare', () => {
136-
const edge = callEdges.find(
137-
(e) =>
138-
e.caller_name === 'ConcreteWorker.doWork' &&
139-
e.callee_name === 'ConcreteWorker.prepare' &&
140-
e.callee_file === 'ConcreteWorker.ts',
141-
);
142-
expect(
143-
edge,
144-
`Expected ConcreteWorker.doWork → ConcreteWorker.prepare edge (this-dispatch).\nActual edges:\n${JSON.stringify(callEdges, null, 2)}`,
145-
).toBeDefined();
146-
});
147-
}
130+
expect(
131+
edge,
132+
`Expected ConcreteWorker.doWork → ConcreteWorker.prepare edge (this-dispatch).\nActual edges:\n${JSON.stringify(callEdges, null, 2)}`,
133+
).toBeDefined();
134+
});
148135

149136
// ── super-dispatch ─────────────────────────────────────────────────────
150-
// Same native gap: super.speak() requires raw call-site receiver info not
151-
// persisted to the DB by the Rust pipeline. See issue #1326.
152137

153-
if (engine === 'native') {
154-
it.todo('super-dispatch: emits Lion.speak → Animal.speak (native gap #1326)');
155-
} else {
156-
it('super-dispatch: emits Lion.speak → Animal.speak', () => {
157-
const edge = callEdges.find(
158-
(e) =>
159-
e.caller_name === 'Lion.speak' &&
160-
e.callee_name === 'Animal.speak' &&
161-
e.callee_file === 'Animal.ts',
162-
);
163-
expect(
164-
edge,
165-
`Expected Lion.speak → Animal.speak edge (super-dispatch via class hierarchy).\nActual edges:\n${JSON.stringify(callEdges, null, 2)}`,
166-
).toBeDefined();
167-
});
168-
}
138+
it('super-dispatch: emits Lion.speak → Animal.speak', () => {
139+
const edge = callEdges.find(
140+
(e) =>
141+
e.caller_name === 'Lion.speak' &&
142+
e.callee_name === 'Animal.speak' &&
143+
e.callee_file === 'Animal.ts',
144+
);
145+
expect(
146+
edge,
147+
`Expected Lion.speak → Animal.speak edge (super-dispatch via class hierarchy).\nActual edges:\n${JSON.stringify(callEdges, null, 2)}`,
148+
).toBeDefined();
149+
});
169150

170151
// ── transitive multi-level CHA (issue #1311) ───────────────────────────
171152
// Hierarchy: IJob → AbstractJob (non-instantiated) → PrintJob / ScanJob

tests/parsers/javascript.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,4 +908,29 @@ describe('JavaScript parser', () => {
908908
);
909909
});
910910
});
911+
912+
describe('Phase 8.3e: extractSpreadForOfWalk — exported arrow function funcStack (#1354)', () => {
913+
it('tracks plain const arrow function on funcStack for for-of loop', () => {
914+
const symbols = parseJS(`const f = (arr) => { for (const x of arr) x(); };`);
915+
expect(symbols.forOfBindings).toContainEqual(expect.objectContaining({ enclosingFunc: 'f' }));
916+
});
917+
918+
it('tracks exported const arrow function on funcStack for for-of loop', () => {
919+
const symbols = parseJS(`export const f = (arr) => { for (const x of arr) x(); };`);
920+
expect(symbols.forOfBindings).toContainEqual(expect.objectContaining({ enclosingFunc: 'f' }));
921+
});
922+
923+
it('records correct varName and sourceName for exported arrow for-of', () => {
924+
const symbols = parseJS(
925+
`export const handleItems = (items) => { for (const cb of items) cb(); };`,
926+
);
927+
expect(symbols.forOfBindings).toContainEqual(
928+
expect.objectContaining({
929+
varName: 'cb',
930+
sourceName: 'items',
931+
enclosingFunc: 'handleItems',
932+
}),
933+
);
934+
});
935+
});
911936
});

0 commit comments

Comments
 (0)