Skip to content

feat(resolve): infer method-call receiver types across languages and prefer same-file targets#119

Merged
sunerpy merged 1 commit into
mainfrom
fix/upstream-r5-receiver-inference
Jul 6, 2026
Merged

feat(resolve): infer method-call receiver types across languages and prefer same-file targets#119
sunerpy merged 1 commit into
mainfrom
fix/upstream-r5-receiver-inference

Conversation

@sunerpy

@sunerpy sunerpy commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Round 5 (final) of the upstream colby 1.1.2→1.2.0 port. Method calls through a variable or typed parameter previously only resolved for C++ (and Java/Kotlin fields); every other language dropped them, so callers/impact couldn't follow obj.method().

  • #1108 — generalize local-variable receiver inference (const x = new T(), x = T(), x := T{}, etc.) across TypeScript, JavaScript, Python, Java, C#, Kotlin, Swift, Go, Rust, Dart, Scala, PHP.
  • #1125 — typed-parameter inference (fn(lg: Logger), TS generics repo: Repository<User> → outer type).
  • #1112 — recognize Lua/Luau :, R $, Pascal . call separators.
  • #1079 — prefer the call site's own file when several same-named methods exist across files, in the three method-call resolution paths that lacked it.

Every inference is validated via resolve_method_on_type, so a wrong type guess yields no edge rather than a wrong one. The C++ (infer_cpp_*) and Java/Kotlin (infer_java_field_*) paths are preserved.

Golden change (upstream-aligned)

The mini golden's 3 local-variable instance-method edges rise from confidence 0.8 → 0.9, matching upstream colby 1.2.0's receiver-inference path (name-matcher.ts matchMethodCall resolves local-var receivers at 0.9; the old 0.8 came from an older upstream reference db). Regenerated colby.db + edges.json accordingly — only those 3 confidence values changed; no edge lost/added/re-targeted. Other fixtures (godot/ruby/mcp) unchanged.

Verification

  • make ci green (fmt + clippy + full test incl. golden equivalence + guardrail)
  • TDD: per-language behavioral tests + negatives (ambiguous/no-type → no edge) + #1079 same-file partition tests + branch-coverage tests
  • Determinism verified: no HashMap/HashSet iteration into resolved-edge output order
  • cross_file_resolution_matches_upstream_golden_edges + upstream_db_is_self_equivalent_to_mini_golden both pass with the 0.9 golden

…prefer same-file targets

Method calls through a variable or typed parameter previously only resolved for
C++ (and Java/Kotlin fields); every other language dropped them, so callers and
impact could not follow `obj.method()`.

Generalize receiver-type inference across TypeScript, JavaScript, Python, Java,
C#, Kotlin, Swift, Go, Rust, Dart, Scala, and PHP:
- local-variable receivers (`const x = new T()`, `x = T()`, `x := T{}`, etc.)
  recover the receiver's type from its initializer (#1108);
- typed parameters (`fn(lg: Logger)`, TS generics `repo: Repository<User>`) use
  the declared type (#1125);
- Lua/Luau `:`, R `$`, and Pascal `.` call separators are recognized (#1112).
Every inference is validated via resolve_method_on_type, so a wrong guess yields
no edge rather than a wrong one, matching upstream colby 1.2.0 confidences.

Also prefer the call site's own file when several same-named methods exist across
files, in the three method-call resolution paths that lacked it (#1079).

The mini golden's three local-variable instance-method edges rise from confidence
0.8 to 0.9, matching upstream colby 1.2.0's receiver-inference path (the old 0.8
came from an older upstream reference db); regenerated colby.db + edges.json
accordingly. Other fixtures unchanged.
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.51613% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/codegraph-resolve/src/name_matcher.rs 99.51% 6 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
+ Coverage   95.52%   95.62%   +0.09%     
==========================================
  Files         115      115              
  Lines       53276    54670    +1394     
==========================================
+ Hits        50894    52280    +1386     
- Misses       2382     2390       +8     
Files with missing lines Coverage Δ
crates/codegraph-resolve/src/name_matcher.rs 97.15% <99.51%> (+1.04%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sunerpy sunerpy merged commit d807080 into main Jul 6, 2026
7 checks passed
@sunerpy sunerpy deleted the fix/upstream-r5-receiver-inference branch July 6, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant