Repository navigation
merge: reconcile upstream through df3ce972 with native auto-local, chain and member receivers - #487
Merged
Merged
Conversation
…class C++ finds, not a namesake (colbymchenry#2532) colbymchenry#2493 resolved calls on declared pointers, values and references by C++ lookup. Calls whose receiver type came from an initializer or a return type still went by the type's last name: - An `auto` local now has the type its initializer has, as written where that is declared: a cast or smart pointer written out (`std::unique_ptr<Iterator>(…)`, `static_cast<InstrumentedMutex*>(arg)`), `new` / `std::make_unique` / a construction of a class, or what a function or method is declared to return (`txn->GetIterator(…)`), with the initializer read to its `;` across lines. Its calls then go through matchCppDeclaredTypeCall from that site. A type that depends on a template parameter (`T*`, `std::shared_ptr<T>`) is left to the old path. - A chained call `a->b()->c()` looks `c` up on the class C++ finds for the written return type of `b`, through a smart pointer too (matchCppChainOnWrittenType), before the last-name path. - A type from outside the project gets no project method: a std/abseil library type (colbymchenry#2413's gate, now applied before the last-name match, so a namesake class like fmt's own `ostream` no longer wins), and a capitalized type under a namespace the project declares no type in (`absl::Status`, which reached `upb::Status::ok`). - A bare call in a method types an `auto` local from the class's own or inherited method; a `template <…>` header followed by macros or specifiers still names its parameters; a trailing annotation macro (`T* PROTOBUF_NONNULL`) is no part of a return type; and memoized `auto` types are worked out with a fresh depth budget, so a deep chain that reads a local first no longer leaves it untyped for its other calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ype's method, wherever the class is declared (colbymchenry#2533) Receiver inference read back through the call's file and the header of the same name only, so a member of a class declared elsewhere — rocksdb's DBImpl is declared in db_impl.h, its methods in db_impl_write.cc, db_impl_compaction_flush.cc, db_impl_open.cc and more — was never read, and calls on it (`versions_->GetColumnFamilySet()`, `mutex_.Lock()`) were guessed by the receiver's name. - Where the scan leaves the calling function, the name is looked up as a data member of the function's class before anything outside it (cppCallersMember): the class's own declaration lines wherever it is declared (the declaration in the caller's own translation unit, of classes sharing a name), then the classes it derives from through their base edges, skipping a base that depends on the template's parameters. A gtest `TEST_F` / `TEST_P` body is a method of a class derived from its fixture, so `db_` there is the fixture's. - The member goes into the declaration record as the caller's own, with its class as the lookup site, so colbymchenry#2493's lookup, the library-type gate and colbymchenry#2440's held-type path apply. A member of a template parameter's type, or of an alias of one, and a name the scan saw an unreadable declaration of, stay as before. (isCppTemplateDependentType now also counts a std trait of a parameter: protobuf's `using MapFieldBase = std::conditional_t<kIsMutable, …>`.) - cppDataMemberIn reads only declarations outside parentheses and not followed by an argument list (method declarations have no nodes, so their parameters are in the class's lines), skips nested functions and classes, follows block comments across lines, and blanks string literals. - A member declared below an inline method that uses it, and a member of the class itself rather than of a class nested in it, are found the same way; cppExpressionType's own member fallback became redundant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in and member receivers Upstream's colbymchenry#2532 and colbymchenry#2533 change C++ receiver resolution in TypeScript files this fork deleted (name-matcher.ts, cpp-namespaces.ts, cpp-type-aliases.ts). The same behavior runs in the native resolver: - An `auto` local has the type its initializer has where that is written: a cast or smart pointer, `new` / `std::make_unique`, a construction, or what a function or method (the caller's own, inherited ones first) is declared to return. A type a template parameter decides is left unread. - A chained call looks up the class its inner call is declared to return, any number of calls deep, through a smart pointer too; a type from outside the project, or one under a namespace the project declares nothing in, reaches no project method. - A data member of the caller's class is also looked up in the classes it derives from (skipping a base that depends on the template's parameters), and in a gtest TEST_F / TEST_P body in the test's fixture. - A template header followed by macros or specifiers still names its parameters. Where the receiver's type cannot be read the fork leaves the call unlinked instead of guessing a method by the receiver's name; five of upstream's new expectations are adjusted to that, and one gains the third call of a chain.
There was a problem hiding this comment.
All reported issues were addressed across 9 files
You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…riables for C++ receivers A chained call spelled with '.' on a returned smart pointer or optional is the type's own member; only '->' reaches what it holds. A variable declared in a for, if or switch initializer shadows an inherited member of the same name. The call-chain length the docs claim is now stated as four calls.
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.
Merges upstream
mainthroughdf3ce972(two commits: colbymchenry#2532, colbymchenry#2533) intofork/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
autolocal 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->b()->c()looks up the classbis 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.TEST_F/TEST_Pbody in the fixture.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.9where upstream guessed@0.7, and the three-call chain test gainsVersionStorageInfo::LevelFiles @0.85, which upstream's single-inner-call reading does not reach.Checks
__tests__/cpp-auto-local-receiver.test.tsand__tests__/cpp-member-receiver.test.ts: 22/22 (16 failed before the port).readme-sync: 28/28). Kernel golden dumps unchanged.npm run eval:precision -- json(C++ corpus): absent 11/11 held, present 7/7 held.tsc --noEmitandcheck:agent-docsclean.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.mdgets upstream's two entries plus a fork note.Summary by cubic
Merges upstream
mainthroughdf3ce972(colbymchenry#2532, colbymchenry#2533) intofork/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
autolocals 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).TEST_F/TEST_Pbody in its fixture..chain on a returnedstd::unique_ptrorstd::optionalis that type's own member; only->reaches what it holds. A variable declared in afor,iforswitchinitializer shadows a same-named inherited member.[], two typed calls read@0.9where upstream guessed@0.7, and the three-call chain test gainsVersionStorageInfo::LevelFiles @0.85.Written for commit 03ae96b. Summary will update on new commits.
Summary by CodeRabbit
autovariables initialized by casts, constructors, factories, and function returns.