You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cha): skip CHA expansion for super-dispatch edges
* fix(cha): skip CHA expansion for super-dispatch edges in runChaPostPass and runPostNativeCha
When a method calls super.method(), the resolver creates an edge from the
subclass method to the parent class method (e.g. PostMixin.m → A.m).
runChaPostPass and runPostNativeCha then incorrectly CHA-expanded this edge
to all sibling subclasses of A (e.g. B from other files that also extend A),
producing false PostMixin.m → B.m edges across unrelated files.
Fix: before BFS-expanding a caller→type.method edge, check whether the
caller's class is itself a direct child of the target type. If so, the edge
was produced by a super.method() call (going up the hierarchy) and must not
be expanded downward to sibling subclasses. This applies to both runChaPostPass
(WASM path) and runPostNativeCha (native orchestrator path), which share the
same CHA expansion loop structure.
Verified by node scripts/parity-compare.mjs --langs jelly-micro: the 6
PostMixin super4 false edges are eliminated; all 3048 tests pass.
* fix(cha): replace heuristic super-dispatch guard with technique-based SQL filter
The direct-child heuristic in runChaPostPass / runPostNativeCha had two
flaws raised in review:
1. False positive: any B.method → A.method edge where B extends A was
treated as a super-dispatch edge, including typed-parameter calls
(param: A).foo() from within B.method, suppressing legitimate CHA
expansion to sibling subclasses.
2. Deep-hierarchy miss: implementors.get(typeName) only returns direct
children. For D extends C extends B, D is not in implementors.get("B"),
so the guard failed to fire and the false expansion still occurred.
Fix: tag super-dispatch edges with technique='super-dispatch' at insertion
time (build-edges.ts for the WASM path, runPostNativeThisDispatch for the
native path). The CHA expansion queries in runChaPostPass and
runPostNativeCha then filter these edges out via SQL
(AND e.technique != 'super-dispatch'), eliminating the heuristic entirely.
Add Tiger.ts sibling fixture and a test asserting Lion.speak does not
CHA-expand to Tiger.speak, covering both the fix and the regression.
Impact: 6 functions changed, 6 affected
`Expected NO Lion.speak → Tiger.speak edge (super-dispatch must not expand to sibling subclasses).\nActual edges:\n${JSON.stringify(callEdges,null,2)}`,
161
+
).toBeUndefined();
162
+
});
163
+
151
164
// ── transitive multi-level CHA (issue #1311) ───────────────────────────
0 commit comments