Skip to content

Reconcile upstream through 16bc05a2 (Go asserted locals, native) - #433

Merged
bompus merged 2 commits into
fork/consolidatedfrom
reconcile/upstream-16bc05a2
Oct 10, 2026
Merged

bompus merged 2 commits into
fork/consolidatedfrom
reconcile/upstream-16bc05a2

Conversation

@bompus

@bompus bompus commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Merges upstream main through 16bc05a2 (upstream colbymchenry#2478) into fork/consolidated.

colbymchenry#2478: a Go local bound from a type assertion (f, ok := w.(http.Flusher), wr := v.(*Wrapper)) has the asserted type. Upstream implements it in src/resolution/name-matcher.ts, which the fork deleted, so the merge keeps that deletion and ports the rule to the native resolver instead:

  • New codegraph-kernel/src/resolve/go_asserted.rs reads the declaration of the receiver in scope from the syntax tree (blocks, if/for/switch initializers, range and type-switch variables, parameters, var specs; comments declare nothing). A := or var whose whole value is one assertion gives the asserted type; any other declaration leaves the call to the existing strategies.
  • The type is found as Go finds it: own package or dot-imported package for a bare name, imported project package for pkg.T, aliases followed. A type from outside the project or a predeclared one links nothing; a type literal or a function-local type is left to the other strategies.
  • Wired into the method-call and no-evidence method-call arms, function refs (register(st.Fetch)), the 2-hop field chain (wr.job.Start()), and the standard-library-package prefilter (a local named parser is the local).
  • Upstream's __tests__/go-asserted-locals.test.ts is kept. Two assertions are adapted to the fork's existing rule that a callee is not name-guessed for a receiver whose type the project does not declare: a type-literal / function-local asserted type (Unseen) and a type-switch variable (Switched) stay unlinked where upstream name-matches them to sink::Drain. Both behave this way on fork/consolidated before this change.

CHANGELOG: this range's entry; a duplicate of an earlier Go-assertion entry the merge re-inserted is dropped. README merge point moved to 16bc05a2.

Checks: full suite 681 files / 8701 tests passed, no worker crashes; golden dumps unchanged; eval:precision gin 3/3 held; kernel built with no warnings.

README rows checked: merge point (2 places) updated; no fork-vs-upstream row changes.

Lands as a merge commit (not squash) to keep upstream ancestry.

Summary by CodeRabbit

  • New Features
    • Go method calls on variables created through type assertions now link to matching methods on project types, including methods promoted from embedded types.
    • Corrected handling of asserted types from outside the project: these calls remain unresolved rather than linking to unrelated project methods.
    • Variables named after standard-library packages are no longer automatically treated as package references when they hold local asserted values.

colbymchenry and others added 2 commits October 10, 2026 07:15
…he asserted type's method (colbymchenry#2478)

Receiver inference read `v := T{}`, `var v T` and parameters, never a
local bound from a type assertion. So `flusher.Flush()` after
`flusher, ok := w.(http.Flusher)` went to whichever project method name
matching picked, and calls like etcd's `fi.Action()` after
`fi := s.kvindex.(*fakeIndex)` linked to nothing.

A Go local whose declaration in scope at the call binds the value of a
type assertion (`v := x.(T)`, `v, ok := x.(T)`, `var v, _ = x.(T)`) now
has the asserted type, found where Go finds it, as colbymchenry#2444 does for a call
made through the assertion itself (`x.(T).M()`). Calls, method values and
field chains through the local (`wr.job.Start()`) reach the type's own
method, its interface's, or one embedding promotes into it. The binding is
the one the scope reader from colbymchenry#2448 finds in scope at the call: an `if`
header's ends with its statement, and a nearer declaration in a block that
has ended does not hide it. A type switch's variable and a value that only
starts with an assertion (`x.(T).field`) resolve as before.

A type from outside the project, a predeclared type or an alias of an
outside type links nothing, as for the assertion itself. A type the index
can't tell is left to name matching, as before: a type literal
(`interface{ GetDeadline() time.Time }`) or a type declared inside a
function (grpc-go's `internalInfo` and `grpcstatus`). A local bound from an
assertion and named like a standard-library package
(`parser, ok := builder.(balancer.ConfigParser)`) is no longer dropped as
a call into that package.

On etcd, harbor, kratos and grpc-go, 358 call sites change. 216 gain a
link, 38 move to the asserted type's method and 89 keep their target, now
resolved through the asserted type. 15 lose a link that went through a
type from outside the project, or from a field read to a same-named
function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the native resolver

Upstream colbymchenry#2478 types a Go local bound from a type assertion in the TypeScript
name matcher, which the fork replaced with the Rust kernel. The same rule is
implemented in codegraph-kernel/src/resolve/go_asserted.rs, reading the
declaration in scope from the syntax tree.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df27f4bb-7255-43c8-a25e-bb270bf46421

📥 Commits

Reviewing files that changed from the base of the PR and between 05d5ad3 and d783a3f.


📒 Files selected for processing (9)
  • CHANGELOG.md
  • README.md
  • __tests__/go-asserted-locals.test.ts
  • codegraph-kernel/src/resolve/fields.rs
  • codegraph-kernel/src/resolve/go_asserted.rs
  • codegraph-kernel/src/resolve/member_fn_ref.rs
  • codegraph-kernel/src/resolve/method_call.rs
  • codegraph-kernel/src/resolve/mod.rs
  • codegraph-kernel/src/resolve/prefilter.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



📝 Walkthrough

Walkthrough

Go receiver resolution now uses types established by local type assertions to find project methods, including promoted methods. Asserted external types do not resolve to project methods. Tests cover resolution cases across the default and WASM backends. The README upstream baseline and changelog entry were also updated.

Changes

Go asserted-local method resolution

Layer / File(s) Summary
Identify and resolve asserted local types
codegraph-kernel/src/resolve/go_asserted.rs, codegraph-kernel/src/resolve/mod.rs
New resolver helpers identify in-scope locals assigned type assertions and classify asserted types as project or outside types.
Apply asserted types to receiver resolution
codegraph-kernel/src/resolve/member_fn_ref.rs, codegraph-kernel/src/resolve/method_call.rs, codegraph-kernel/src/resolve/fields.rs, codegraph-kernel/src/resolve/prefilter.rs
Member, method-call, field-chain, and standard-library prefilter paths now check asserted-local resolution before or alongside existing receiver inference.
Validate and document resolution
__tests__/go-asserted-locals.test.ts, CHANGELOG.md
Tests cover asserted types, scope and shadowing cases, method values, and unlinked decoys across both backends. The changelog records the resolution behavior.

README upstream reference

Layer / File(s) Summary
Update upstream comparison baseline
README.md
The fork description and feature comparison now identify upstream commit 16bc05a2.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to d783a

The asserted-local resolution change has no identified issue requiring a fix before merge.

Pre-merge checks | Passed 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the upstream reconciliation through commit 16bc05a and the main feature, Go asserted-local resolution. It is concise and related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Suppressions Explained Passed The pull request adds no lint, type-check, or compiler suppression directive. The changed files contain no new eslint-disable, @ts-expect-error, @ts-ignore, #[allow(...)], noqa, or lint/type…
User-Visible Changes Documented Passed The pull request changes Go resolver behavior, tests, CHANGELOG.md, and README.md merge-point references. It does not add, remove, or rename a CLI command or flag, MCP tool or argument, supported lang…

✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@bompus
bompus merged commit 20a7a12 into fork/consolidated Oct 10, 2026
6 of 7 checks passed
@bompus
bompus deleted the reconcile/upstream-16bc05a2 branch October 10, 2026 08:25
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.

2 participants