-
Notifications
You must be signed in to change notification settings - Fork 15
fix(resolver): qualified callerName mismatch in class-scoped typeMap lookup #1403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
e206fbe
2ce58cd
0831e36
98ad971
c1a32c5
5617de8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1545,48 +1545,28 @@ export async function tryNativeOrchestrator( | |||||||||
| } | ||||||||||
|
|
||||||||||
| // Phase 8.5: expand CHA call edges (interface dispatch → concrete implementations). | ||||||||||
| // `runPostNativeCha` returns the target node IDs of newly inserted edges so we | ||||||||||
| // can re-classify roles for the implementation files. The Rust orchestrator ran | ||||||||||
| // role classification BEFORE this post-pass, so without a re-run the newly-called | ||||||||||
| // implementor methods stay classified as `dead-ffi` (no incoming edges at Rust time). | ||||||||||
| // The Rust orchestrator ran role classification BEFORE this post-pass, so without | ||||||||||
| // a re-run the newly-called implementor methods stay classified as `dead-ffi`. | ||||||||||
| // | ||||||||||
| // CHA also changes the global fan-out distribution (callee files gain fan_in, and | ||||||||||
| // new edges shift the median). A full re-classification is required — not just the | ||||||||||
| // callee files — because the median shift can change roles in unrelated files whose | ||||||||||
| // fan-out sits near the old median. (Example: a method that called two siblings | ||||||||||
| // pre-CHA might be near the median, but post-CHA the median is higher, changing | ||||||||||
| // its role from utility → core.) Using an incremental pass with a stale median | ||||||||||
| // cache would produce incorrect roles outside the CHA-affected file set. | ||||||||||
| const chaTargetIds = runPostNativeCha(ctx.db as unknown as BetterSqlite3Database); | ||||||||||
| if (chaTargetIds.size > 0) { | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed — changed |
||||||||||
| try { | ||||||||||
| const db = ctx.db as unknown as BetterSqlite3Database; | ||||||||||
| const idArray = Array.from(chaTargetIds); | ||||||||||
| const CHUNK_SIZE = 500; | ||||||||||
| const seenFiles = new Set<string>(); | ||||||||||
| const affectedFiles: Array<{ file: string }> = []; | ||||||||||
| for (let i = 0; i < idArray.length; i += CHUNK_SIZE) { | ||||||||||
| const chunk = idArray.slice(i, i + CHUNK_SIZE); | ||||||||||
| const placeholders = chunk.map(() => '?').join(','); | ||||||||||
| const rows = db | ||||||||||
| .prepare( | ||||||||||
| `SELECT DISTINCT file FROM nodes WHERE id IN (${placeholders}) AND file IS NOT NULL`, | ||||||||||
| ) | ||||||||||
| .all(...chunk) as Array<{ file: string }>; | ||||||||||
| for (const row of rows) { | ||||||||||
| if (!seenFiles.has(row.file)) { | ||||||||||
| seenFiles.add(row.file); | ||||||||||
| affectedFiles.push(row); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| if (affectedFiles.length > 0) { | ||||||||||
| const { classifyNodeRoles } = (await import('../../../../features/structure.js')) as { | ||||||||||
| classifyNodeRoles: ( | ||||||||||
| db: BetterSqlite3Database, | ||||||||||
| changedFiles?: string[] | null, | ||||||||||
| ) => Record<string, number>; | ||||||||||
| }; | ||||||||||
| classifyNodeRoles( | ||||||||||
| db, | ||||||||||
| affectedFiles.map((r) => r.file), | ||||||||||
| ); | ||||||||||
| debug( | ||||||||||
| `CHA post-pass: re-classified roles for ${affectedFiles.length} implementation file(s)`, | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| const { classifyNodeRoles } = (await import('../../../../features/structure.js')) as { | ||||||||||
| classifyNodeRoles: ( | ||||||||||
| db: BetterSqlite3Database, | ||||||||||
| changedFiles?: string[] | null, | ||||||||||
| ) => Record<string, number>; | ||||||||||
| }; | ||||||||||
| classifyNodeRoles(db); | ||||||||||
| debug(`CHA post-pass: full role re-classification after ${chaTargetIds.size} new CHA edges`); | ||||||||||
| } catch (err) { | ||||||||||
| debug(`CHA post-pass role re-classification failed: ${toErrorMessage(err)}`); | ||||||||||
| } | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WASM counterpart in
call-resolver.ts(line 192) appliescomputeConfidence >= 0.5when buildingsameClass, but the Rust path here only filters byn.kind == "method". If two separate packages in the same graph both define aClassName.MethodNamemethod (e.g. same-named utility classes in different sub-projects), the Rust resolver will return all matches with equal weight, while WASM would keep only the ones that pass the confidence threshold. This pre-existed for receiver-based calls but now also fires for no-receiver static siblings, slightly widening the exposure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed — added
import_resolution::compute_confidence(rel_path, &n.file, None) >= 0.5to the class-scoped Rust lookup, aligning it with the WASM counterpart incall-resolver.ts. Committed in d7cc1cb.