merge: reconcile upstream through df3ce972 with native auto-local, chain and member receivers

Merged
BO
4d ago
+1610-29

Merges upstream main through df3ce972 (two commits: #2532, #2533) into fork/consolidated.

Both commits change C++ receiver resolution in TypeScript files this fork deleted (name-matcher.ts, cpp-namespaces.ts, cpp-type-aliases.ts), so the merge keeps the deletions and ports the behavior into the native resolver (codegraph-kernel/src/resolve/cpp_range_for.rs, cpp_receivers.rs, cpp_implicit_this.rs, cpp_namespace.rs).

Behavior

  • An auto local has the type its initializer has where that is written: a cast or smart pointer written out, new / std::make_unique, a construction, or what a function or method is declared to return (the caller's own class's method first, inherited ones included). A type a template parameter decides is left unread.
  • A chained call a->b()->c() looks up the class b is declared to return, through a smart pointer too, and any number of calls deep. A standard or abseil type, and a capitalized type under a namespace the project declares nothing in (absl::Status), reaches no project method.
  • A data member of the caller's class is also looked up in the classes it derives from (a base that depends on the template's parameters is skipped), and in a gtest TEST_F / TEST_P body in the fixture.
  • A template <…> header followed by macros or specifiers still names its parameters.

Where this differs from upstream

Where a receiver's type cannot be read (a template parameter's, a std::shared_ptr<T> of one, a trait of one, what a function template returns), the fork leaves the call unlinked; upstream's by-name guess lands at 0.7. That is the fork's existing rule for receivers it cannot type, so five of upstream's new expectations are changed to [] (each with a comment naming upstream's value), two typed calls read @0.9 where upstream guessed @0.7, and the three-call chain test gains VersionStorageInfo::LevelFiles @0.85, which upstream's single-inner-call reading does not reach.

Checks

  • __tests__/cpp-auto-local-receiver.test.ts and __tests__/cpp-member-receiver.test.ts: 22/22 (16 failed before the port).
  • Full suite: 8,948 passed, 39 skipped (the only failure in the run was an ordering mistake in my own updated expectation, fixed and re-run with readme-sync: 28/28). Kernel golden dumps unchanged.
  • npm run eval:precision -- json (C++ corpus): absent 11/11 held, present 7/7 held.
  • tsc --noEmit and check:agent-docs clean.

README rows checked

"About this fork": the upstream merge point (now df3ce972) and the C++ differences list (one bullet added for auto locals, chains and member receivers). No other table row or measured number moves; CHANGELOG.md gets upstream's two entries plus a fork note.


Summary by cubic

Merges upstream main through df3ce972 (#2532, #2533) into fork/consolidated, porting both upstream C++ receiver-resolution changes into the native resolver, since the fork deleted the TypeScript files they touched (name-matcher.ts, cpp-namespaces.ts, cpp-type-aliases.ts).

Behavior

  • auto locals now take the type their initializer writes where it is declared: a cast or smart pointer, new/std::make_unique, a construction, or a function or method's declared return type (the caller's own class's method first, inherited included).
  • A chained call resolves the class its inner call is declared to return, any number of calls deep and through smart pointers; a type from outside the project, or under a namespace the project declares nothing in, reaches no project method.
  • A data member of the caller's class is looked up in the class's declarations wherever they are, in classes it derives from (skipping bases that depend on template parameters), and in a gtest TEST_F/TEST_P body in its fixture.
  • A . chain on a returned std::unique_ptr or std::optional is that type's own member; only -> reaches what it holds. A variable declared in a for, if or switch initializer shadows a same-named inherited member.
  • Where a receiver's type cannot be read (a template parameter's, a trait of one, a function template's return), the call stays unlinked rather than receiving upstream's by-name guess at 0.7; five upstream expectations change to [], two typed calls read @0.9 where upstream guessed @0.7, and the three-call chain test gains VersionStorageInfo::LevelFiles @0.85.
  • New tests pass 22/22; full suite 8,948 passed; kernel golden dumps unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Improved C++ call resolution for auto variables initialized by casts, constructors, factories, and function returns.
    • Resolved calls through chained expressions and class data members using declared types, including inherited members and test fixtures.
    • Improved resolution for members declared across files and variables declared in control-flow initializers.
    • Correctly handled member access through returned smart pointers and optionals.
    • Avoided linking calls when types are unresolved or template-dependent, or when external types merely share a name with project classes.
  • Documentation
    • Updated the README with C++ call-resolution details and the upstream baseline.