| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…st-resort fallback (#2139) Native's CHA dispatch (resolve_cha_dispatch, added by #2236) only ran as tier 3.7 inside resolve_call_targets' mutually-exclusive resolution cascade — reached only when every earlier tier found nothing. WASM's equivalent (emitChaCallEdgesForCall) runs unconditionally as an additive Step 6, independent of what the rest of the cascade already resolved. This mattered because an earlier tier (import-aware resolution, which matches call.name regardless of receiver) can return a target and short-circuit the whole cascade before CHA ever runs. Concretely: src/shared/hierarchy.ts's resolveViaRepo calls repo.getClassHierarchy() where repo: Repository has three implementers (InMemoryRepository/NativeRepository/SqliteRepository) — but getClassHierarchy is ALSO an importable free function, so tier 1 matched on the name alone and returned before CHA could expand the interface dispatch. Native produced zero edges to any implementer; WASM produced three. Fix: emit_cha_dispatch_edges runs unconditionally from process_file's per-call loop, alongside emit_call_edges/emit_receiver_edge, mirroring emitChaCallEdgesForCall exactly (same type_map lookup, same resolve_cha_dispatch BFS, same CHA_TYPED_DISPATCH_CONFIDENCE, same 'cha' technique tag). this/self/super dispatch is excluded — that stays with runPostNativeThisDispatch. Verified against this repo's own resolveViaRepo/Repository example (native now correctly emits CHA edges to InMemoryRepository and NativeRepository — SqliteRepository still needs #2346's separate RTA fix, since it's only ever instantiated via an object-literal property value) and via scripts/parity-compare.mjs against the javascript/typescript/tsx/pts-javascript fixtures (byte-identical node and edge counts on both engines). Updated cha_typed_dispatch_fallback_does_not_override_successful_proximity_lookup, which encoded the old (never actually WASM-parity-correct) mutually- exclusive assumption — both the direct proximity hit and the additive CHA edge now coexist, matching real WASM behavior. Filed #2346 (RTA new_expressions gap), #2347 (possible WASM cross-fixture false positives, unrelated direction), and #2348 (odd zero-line edges) for the issue's other, lower-priority observations. docs check acknowledged. Impact: 8 functions changed, 2 affected
Greptile SummaryThe PR makes native typed-receiver CHA dispatch additive so earlier resolution tiers no longer prevent implementer edges from being emitted.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Call["Typed receiver call"] --> Cascade["Primary resolution cascade"]
Call --> CHA["Additive CHA expansion"]
Cascade --> Direct["Direct/import-aware edges"]
CHA --> Implementers["Instantiated implementer edges"]
Direct --> Dedup["Target-level edge deduplication"]
Implementers --> Dedup
Dedup --> Graph["Final call graph"]
Reviews (2): Last reviewed commit: "style: run cargo fmt on emit_cha_dispatc..." | Re-trigger Greptile |
Sorry, something went wrong.
Codegraph Impact Analysis8 functions changed → 2 callers affected across 1 files
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Closes #2139
Native's CHA dispatch (resolve_cha_dispatch, added by #2236) only ran as tier 3.7 inside resolve_call_targets' mutually-exclusive resolution cascade — reached only when every earlier tier found nothing. WASM's equivalent (emitChaCallEdgesForCall) runs unconditionally as an additive Step 6, independent of what the rest of the cascade already resolved.
This mattered because an earlier tier (import-aware resolution, which matches call.name regardless of receiver) can return a target and short-circuit the whole cascade before CHA ever runs. Concretely: src/shared/hierarchy.ts's resolveViaRepo calls repo.getClassHierarchy() where repo: Repository has three implementers (InMemoryRepository/NativeRepository/SqliteRepository) — but getClassHierarchy is also an importable free function, so tier 1 matched on the name alone and returned before CHA could expand the interface dispatch. Native produced zero edges to any implementer; WASM produced three.
Fix
emit_cha_dispatch_edges runs unconditionally from process_file's per-call loop, alongside emit_call_edges/emit_receiver_edge, mirroring emitChaCallEdgesForCall exactly (same type_map lookup, same resolve_cha_dispatch BFS, same CHA_TYPED_DISPATCH_CONFIDENCE, same 'cha' technique tag). this/self/super dispatch is excluded — that stays with runPostNativeThisDispatch.
Verification
Test plan
Filed #2346 (RTA new_expressions gap), #2347 (possible WASM cross-fixture false positives — unrelated direction, needs its own investigation per the issue's own notes), and #2348 (odd zero-line edges) for the issue's other, lower-priority observations not addressed here.