Repository navigation
fix(resolution): calls between C, C++ and Objective-C files link by name - #3052
Merged
Merged
Conversation
Name matching compared a candidate's raw language tag with the reference's: the single-candidate confidence in matchByExactName and matchFuzzy, and findBestMatch's same-language skip and +50/-80 score. So a call whose name had several definitions in another of C, C++ and Objective-C scored -80 for each and linked to nothing (an Objective-C file's _glfwPlatformSetTls(), a C++ call into Dear ImGui's imgui.h, which reads as C), and the one definition of a name across TSX and TS, or C and C++, was a 0.5 cross-language guess. The single-candidate confidence now compares language families (sameLanguageFamily). Ranking treats C, C++ and Objective-C as one language (sameRankingLanguage), the very language worth a point that only breaks a tie; other families keep the language itself, because ranking them by family moved excalidraw's Store::scheduleCapture calls to the App.tsx method beside them and gave okhttp 83 wrong Java-to-Kotlin Builder picks. Validation: - __tests__/name-match-language-family.test.ts, 8 tests (default and wasm): 6 fail on the base main; the pin that a .ts call keeps its .ts target over a .tsx namesake beside it passes on both; all pass with the fix. 24 related test files (cross-language, React Native, Expo, Fabric, frameworks, mixed TS/JSX, Objective-C, resolution): 746 pass. - A/B, main vs fix: glfw +4 calls from Objective-C into C, imgui +93 from C++ into imgui.h (read as C) and imstb_rectpack.h, all to the definitions meant; excalidraw, okhttp, leveldb and jq gain or lose no edge (43, 9, 97 and 30 unique-name links go from 0.5 to 0.9 with the same targets); flask and gin byte-identical. - Index time, median of 3 interleaved: imgui 7.9 s main, 7.7 s fix; excalidraw 9.2 s main, 9.4 s fix. Reimplements PR #1662 by ferrine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 30, 2026
inth3shadows
added a commit
to inth3shadows/codegraph
that referenced
this pull request
Oct 30, 2026
Brings 9f379af..bc9291a (colbymchenry#3030, colbymchenry#3031, colbymchenry#3043, colbymchenry#3045, colbymchenry#3046, colbymchenry#3049, colbymchenry#3044, colbymchenry#3047, colbymchenry#3051, colbymchenry#3050, colbymchenry#3052, colbymchenry#3053, colbymchenry#3025, colbymchenry#3055). Clean auto-merge.
bompus
added a commit
to bompus/codegraph
that referenced
this pull request
Oct 31, 2026
…one candidate is judged by family (colbymchenry#3052) Name matching compared a candidate's raw language tag with the reference's: the single-candidate confidence in matchByExactName and matchFuzzy, and findBestMatch's same-language skip and +50/-80 score. So a call whose name had several definitions in another of C, C++ and Objective-C scored -80 for each and linked to nothing, and the one definition of a name across TSX and TS, or C and C++, was a 0.5 cross-language guess. The single-candidate confidence now compares language families; the fork's language_family keeps C, C++, Objective-C and Swift apart where upstream merges them as 'native', so the check reads the fork's code_interop_group instead. Ranking treats C, C++ and Objective-C as one language (same_ranking_language), the very language worth a point that only breaks a tie; other families keep the language itself. One fork addition upstream does not need: with `.h` names now ranking as C++ same-language candidates, an unbound C or C++ receiver could reach the free name-guess fallback and link to a header lookalike. The fallback now skips C and C++ receivers outright, matching the documented fork rule that such a call stays unlinked wherever the receiver's written type cannot be read. Ported from upstream 6d3804c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Name matching weighed a candidate by its raw language tag, so calls between C, C++ and Objective-C files were treated as crossing languages: a call whose name had more than one definition in the other two languages linked to nothing, and the one definition of a name was a 0.5 "cross-language" guess. Now:
.tsxcomponent calling the only.tsfunction of its name, or a C test calling the C API that a.ccfile defines, is a 0.9 match instead of 0.5;.hfile is C, C++ or Objective-C only as far as sniffing its text can tell (Dear ImGui's C++imgui.hreads as C). An Objective-C.mfile's_glfwPlatformSetTls(…), which glfw defines in bothposix_thread.candwin32_thread.c, now links to the nearer one; before, both scored −80 and the call linked to nothing.Reimplements #1662 by @ferrine. Its headline (dropping cross-family bare-name calls) landed with #2032; this is the raw-tag-versus-family comparison it also pointed at.
Root cause
matchByExactName's single-candidate confidence,findBestMatch's same-language skip and its +50/−80 language score, andmatchFuzzy's single-candidate confidence all comparedcandidate.language === ref.language. They predatesameLanguageFamily, which the cross-family gate already uses.Fix, and why the ranking change is narrower than the diagnosis
findBestMatchand theweighedset beside it compare throughsameRankingLanguage: the same language, or both of C, C++ and Objective-C, with the very language worth one point, which only breaks a tie (a directory nearer counts 15).Ranking every family by family, as the triage proposed, was measured and rejected. With it, excalidraw's
this.app.store.scheduleCapture()calls in theApp.*.tsfiles moved fromStore::scheduleCapture(right) toApp::scheduleCapturein theApp.tsxbeside them (wrong), a JSON import was linked to a constant in a build script, and okhttp gained 83 Java-to-Kotlinnew X.Builder()/X.Factoryguesses onto whicheverBuilderwas nearest (new OkHttpClient.Builder()→MockResponse.Builder). In those families files reach each other's names through imports, and the raw tag had been keeping a name-only pick inside one language. The new test pins the excalidraw shape.Validation
New
__tests__/name-match-language-family.test.ts(8 tests, default and wasm): TSX → the one TS function at 0.9; a.tscall still ranked to the.tsclass over a same-named.tsxmethod beside it; Objective-C → C (the one function at 0.9, the nearer of two); C++ → C (the nearer of two). On the base main 6 fail (the ranking pin passes on both); all 8 pass with the fix.A/B, base main vs fix (wasm on both arms; resolution only; repo commits in parentheses):
nsgl_context.m→posix_thread.c's_glfwPlatformSetTls/GetTlsandmacos_time.c's timer functions, the macOS build'sg.ColorStack.back()/pop_back()/erase()/find()→ImVector's methods inimgui.h(85),stbrp_pack_rects/stbrp_init_targetinimstb_rectpack.h(2),ImWchar(…)conversions to its typedef (6, as a same-language C++ call already links)db/c_test.c→leveldb_getindb/c.ccjq_initinsrc/execute.c.ts/.tsx, e.g.CanvasRenderingContext2D,AppOkHttpClient,OkHttpClientTestRuleMain moved under this branch three times in
name-matcher.ts(fix(python): a parameter or local named like an imported module is not that module #3046 Python, fix(ruby): calls to!/?methods and calls on what.newmade link their method #3049 Ruby, fix(jvm): a dotted supertype names its nested type, and a Kotlin object expression is an anonymous class #3051 JVM). After each rebase the A/B on glfw, imgui, excalidraw, okhttp and flask was re-run on the kernel path against that main (kernel rebuilt), and gave the same deltas each time; the test fails 6 of 8 with the resolver of the fix(ruby): calls to!/?methods and calls on what.newmade link their method #3049 and fix(jvm): a dotted supertype names its nested type, and a Kotlin object expression is an anonymous class #3051 mains (the final base's resolver is fix(jvm): a dotted supertype names its nested type, and a Kotlin object expression is an anonymous class #3051's) and passes 8 of 8 with the fix on every base.Index time, kernel path, median of 3 interleaved: imgui 7.9 s main, 7.7 s fix; excalidraw 9.2 s main, 9.4 s fix (noise).
24 related test files (cross-language, React Native and Expo bridges, Fabric, frameworks, mixed TS/JSX, Objective-C, resolution, PR19): 746 passed, 0 failed.
Full suite on this exact commit (base main 19b74d1, kernel built,
CODEGRAPH_KERNEL_EXPECT=1,CODEGRAPH_NO_DAEMONunset, 4 workers): 801 files, 9,520 passed, 0 failed, 86 skipped.Left out
imgui.hbeing read as C is a header-detection question of its own; its new links land onImVector's inline methods as the C parse extracts them.pr1662-rankfixture (a.tsxcall with a.tssibling and a far.tsxnamesake) still picks the.tsxone.🤖 Generated with Claude Code