Skip to content

fix(js,ts): a named class expression is a class with its own members - #2825

Merged
colbymchenry merged 1 commit into
mainfrom
claude/issue-2499-class-expressions
Oct 23, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/issue-2499-class-expressions

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Summary

Fixes #2499. Both engines now index a named class expression as a class, with its methods, properties, extends and implements. That covers register(class Widget extends Base {…}), const Panel = class PanelImpl extends Base {…}, customElements.define('x-card', class XCard extends HTMLElement {…}) and module.exports = class Router {…}. Calls inside the class link as they do in a class declaration: this.run() to its own method, super.run() to the parent's (through #2818's matcher), and Widget.build() to the static method.

The name stays scoped as JavaScript scopes it:

  • new Widget() outside the expression links nothing.
  • A same-named class, constant or interface outside keeps its links.
  • Code outside never reaches the class's methods by a name guess.

A class a CommonJS module exports is the exception: module.exports = class Router {…} or exports.Store = class Store {…}. That class is the module's value, and require hands it to every importer. So it reads as a declaration does, and a require of it reaches the class, its static methods and the methods called on its instances.

Root cause

Both extractors treated class_declaration (and TypeScript's abstract_class_declaration) as a class, but not tree-sitter's class node, which is what a class expression parses as. Its body was then walked as plain code, so:

  • methods became free functions (function run), or, in a variable's initializer, weren't indexed at all (const Panel = class PanelImpl {…} gave only constant Panel);
  • there were no extends or implements references;
  • this, super and static calls had no class to start from.

The free functions were also targets for bare-name guesses from anywhere. For example, webpack's module.exports = class MultiCompiler {…} had its methods as functions, so a call to _runGraph's parameter run linked to MultiCompiler's run.

Fix

Extraction, in both engines (src/extraction/tree-sitter.ts, languages/typescript.ts, languages/javascript.ts, the kernel's tsjs/mod.rs and tsjs/extractors.rs):

  • In TS, TSX, JS, JSX and ArkTS, a class node with a name is a class type. An anonymous one is passed over, as before.
  • The class's signature is its head (class Widget extends Base), which marks it as an expression, since a declaration's signature is null. The class is never exported by itself.
  • Members nest under it as in a declaration: Widget::run, and Panel::PanelImpl::go for an initializer, which keeps the variable's name in front as other initializer members do.

Resolution (src/resolution/js-class-expressions.ts, src/resolution/index.ts):

  • Outside every class expression. A reference from a TS, TSX, JS, JSX, ArkTS, Vue, Svelte or Astro file resolves in a view of the graph that hides every scoped class expression and its members:
    • name, qualified-name, kind, in-file and method lookups filter;
    • the known-names pre-filter treats a name that only class expressions carry as unknown, which keeps the view as cheap as the full graph.
  • Inside a class expression. A reference sees the whole graph, unless it names another class expression (by the name, or the head of a dotted name). Then it gets the outside view too.
  • A class a CommonJS module exports isn't scoped. That's a class right after module.exports =, exports.X = or module.exports.X =, which the resolver reads from the source in front of it.
  • Imports. The lookups the import resolver reads a module's exports by are left whole.
  • Named CommonJS exports (src/resolution/alias-binding.ts): the reader of exports.X = … now takes exports.Store = class StoreImpl {…} too, so const { Store } = require('./store') reaches StoreImpl. Before, it took only functions and identifiers.

Validation

  • New test __tests__/js-class-expressions.test.ts (13 tests). On main d5fc1fb, 11 fail. All 13 pass on the fix. The tests cover:

    • extraction in .ts, .tsx, .js and .jsx through the kernel and wasm, with kernel/wasm agreement on every node and reference;
    • scope in .js and .ts: new Widget() outside, another class expression's name inside one, a same-named declaration and constant, a static Tool.make(), and nitro's interface-and-class-expression shape;
    • lit's DOM-shim shape, where document.createElement(…) and container.appendChild(…) must not guess into the shim's methods;
    • CommonJS: module.exports = class Router with new Router(), Router.make() and r.route() on an instance; exports.Store = class StoreImpl with Store.open(); and a scoped register(class Hidden …) next to them.

    The 2 tests that pass on main are kernel/wasm agreement and the lit-shaped guard. Mutating each of 7 parts fails a test:

    • the view;
    • the inside check;
    • the name rule;
    • the expression marker;
    • the class node;
    • the CommonJS export rule;
    • the named-export reader.
  • The issue's repro (V1's files, through both engines, which give identical edges):

    • class Widget with Widget::run and Widget::extra, extends Widget -> Base, super.run() -> Base::run and this.run() -> Widget::run;
    • Panel::PanelImpl with go and helper;
    • XCard with connectedCallback -> XCard::render;
    • new Gadget() outside its expression stays unresolved.
  • Declaration parity: a fixture with the same class written as a declaration and as a class expression gives the same edges for super.run(), this.run(), this.base() and Widget.build(). Through require, the same holds for module.exports = class against module.exports = Foo, and for exports.Store = class against exports.Router = Router, for static and typed instance calls.

  • A/B against main d5fc1fb on 22 repos (20 TS/JS, plus flask and gin), each arm indexed fresh:

    • 193 classes are added in 10 repos, with their members;
    • 801 edge sites change in 7 repos: jest 669, lit 75, webpack (lib) 38, nitro 7, memfs 6, webdriverio 5, vite 1;
    • each was bucketed by kind and cause, and samples from every bucket were checked by hand against the source.
    sites what
    jest's global test() 563 0.4 guesses that move from one wrong namesake to another. The old one, test() in an e2e fixture's module.exports = class Test {…}, is now a method, which a bare call doesn't reach.
    structure 85 new extends, implements and type references of class expressions: lit's SSR shim classes implements MediaListInterface, webpack's module.exports = class FallbackModuleFactory extends ModuleFactory, memfs's FileSystemObserver
    moved to the member 74 calls, news and references now come from the method they are written in, not the constant or file around it
    gained or changed 65 see below
    removed 14 11 guesses into scoped class-expression members from outside, like lit's import { render } from 'lit' landing on a shim's render, and webpack's call to the parameter run. Also 3 super calls whose parent the index can't name: nitro's class extending vite's DevEnvironment, and webpack's extends (ESMImportDependency.Template). Each had gone to the wrong method.

    The 65 that gain or change a target:

    • Inside class expressions, 24:
      • lit's shim Element.toggleAttribute calls its own hasAttribute, removeAttribute and setAttribute. The last went to ElementRenderer::setAttribute before.
      • The shim's Event.stopImmediatePropagation and CSSStyleSheet.replace call their own methods too.
      • webpack's CssIcssExportDependencyTemplate makes 12 calls to its own statics, and MultiCompiler.close calls this.watching.close(). One this.replaceCall() goes from 0.7 to 0.9.
      • nitro's and jest's this.#onInit?.(), this.devServer.close?.(), this.specFilter(spec) and this.it(…).
      • One is a guess: lit's scoped-registry mixin, whose superclass is a parameter, calls this.attachShadow(), which now reaches the SSR shim's Element.attachShadow, as it would were the shim a declaration.
    • Through require, 31:
      • SizeLimitsPlugin.isOverSizeLimit(…) reaches the static method.
      • compiler.setDependencies(…) on a new MultiCompiler(…) reaches MultiCompiler::setDependencies.
      • jest's 10 localClass.test() and scopedInstance.test() calls on a new TestClass() reach Test::test.
      • 18 new X() calls reach the class, 14 of them rather than the local constant require was assigned to.
    • Synthesized edges, 6: override edges of new subclasses, like TestClassA::constructor → Child::constructor, as declarations get.
    • Guess churn, 4: webpack's factory.create(…) calls on an untyped factory move from one 0.65 guess to another, ContextModuleFactory::create to ContainerEntryModuleFactory::create. Neither is the one called.

    Nodes and edges are unchanged in 12 repos, the controls among them, and their dumps are byte-identical. nuxt, social-app and outline gain only nodes.

  • Kernel parity (scripts/kernel-parity.mjs): no file differs on 22 repos. On the final build, lit, webpack, memfs, nitro, webdriverio and jest give the same counts and deferrals as that sweep.

  • Sync: three CLI scenarios match a fresh index:

    • a parent moving and gaining a method that a class expression's super call then reaches;
    • a shim class expression gaining a member while another file starts importing it;
    • one module starting to export its class expression while another stops, with the importer edited.

    One case stays stale, and it's pre-existing: an importer that isn't edited keeps what it resolved when only the other module's module.exports line changes. Declarations on main do the same (checked with module.exports = Store becoming module.exports = {}, and the reverse).

  • Index time, median of 5 interleaved runs:

    repo main fix change
    lit 9.17 s 9.24 s +0.8%
    webpack (lib) 11.18 s 11.48 s +2.7%
    jest 11.80 s 11.87 s +0.6%
    insomnia 14.56 s 16.42 s +12.8%

    insomnia's gap is other jobs' load on the machine, not this change. It holds no class expression and indexes byte-identically, and its resolver time, profiled twice per arm, is the same on both: 25.5 and 26.4 s on the fix against 25.5 and 25.9 s on main. The A/B's own 3 rounds gave lit +1.1%, webpack +0.8% and jest −5.1%.

  • Base: the branch is on main 23a80a8. The A/B, parity and timing ran against d5fc1fb, and the two commits between, fix(kotlin): repository().pending() links the method of the type repository() declares #2822 and fix(python): a from-import of a module with no dot in its name links the module's file #2823, change Kotlin and Python resolution only.

  • Full suite on this commit (CODEGRAPH_KERNEL_EXPECT=1, kernel rebuilt on the rebased branch): 735 test files passed and 6 skipped; 8,799 tests passed, 82 skipped, none failed.

Left out

  • Class values beyond require. Resolution doesn't track values, and the issue scopes this out too. This covers:
    • export const Panel = class PanelImpl {…} used as Panel.make() from another module;
    • a class a factory returns;
    • X.Template = class XTemplate {…}.
  • A heritage written as a member expression, like webpack's extends (ESMImportDependency.Template), gives no extends edge, for declarations and expressions alike. So a super call there links nothing.
  • A pre-existing gap: an inherited this.run() with a same-named method elsewhere in the file links to that namesake at 0.4 rather than the parent's method. Class declarations do the same on main.

I read contributor PR #2500 by @Puma7, who also reported the issue, for guidance. This implementation and its tests are our own, and the CHANGELOG credits @Puma7 for both.

🤖 Generated with Claude Code

A named class expression, like register(class Widget extends Base {})
or module.exports = class Router {}, was not indexed as a class, as
issue #2499 found. Its methods became free functions, its fields and
supertypes were dropped, and calls in it had no class to start from,
so its this-calls, super calls and own static calls went unresolved or
to a by-name guess, and calls elsewhere guessed into its methods.

Both engines now index a named class expression as a class, with its
methods, properties, extends and implements. An anonymous one is still
passed over. Its head (class Widget extends Base) is its signature,
which marks it as an expression, and it is never exported by itself.

JavaScript binds the name only inside the expression, and the resolver
now scopes it the same way. A reference written outside every class
expression resolves in a view of the graph that hides class
expressions and their members, so new Widget() elsewhere links
nothing, and a same-named class, function or binding keeps its links.
A name only class expressions carry is unknown there. A reference
inside one sees the whole graph, unless it names another class
expression. A class a CommonJS module exports, module.exports = class
Router {} or exports.Store = class Store {}, is the module's value,
which require hands to every importer, so it is not scoped: it reads
as a declaration does, and a require of it reaches its static methods
and its instances' methods. The reader of CommonJS named exports takes
exports.X = class Y {} too. Super calls in a class expression now
resolve through the super-call matcher.

Validation: the new test fails 11 of 13 on main d5fc1fb and passes 13
of 13 on the fix, and a mutation of each of 7 parts (the view, the
inside check, the name rule, the expression marker, the class node,
the CommonJS export rule, the named-export reader) fails a test.
A/B against main d5fc1fb on 22 repos (20 TS/JS, flask and gin): 193
classes are added in 10 repos with their members, and 801 edge sites
change in 7 repos, each bucketed and sampled by hand. 563 are jest's
calls to its global test(), 0.4 guesses that move from one wrong
namesake to another: the old one, a class expression's test() in an
e2e fixture, is now a method. Of the rest, 85 are new extends,
implements and type references of class expressions; 74 calls, news
and references move to the member they are written in; 65 calls and
news gain or change a target, inside class expressions (this-calls,
own static calls) and through require (static calls, typed instance
calls, new); and 14 guesses are removed, among them 3 super calls
whose parent the index can't name. 12 repos' dumps, the controls among
them, are byte-identical. Kernel parity holds on 22 repos. Three sync
scenarios match a fresh index. Index time, median of 5 interleaved
runs: lit +0.8%, webpack +2.7%, jest +0.6%; insomnia +12.8%, though it
indexes byte-identically, holds no class expression, and its resolver
time is the same on both arms, so that gap is other jobs' load.

Fixes #2499

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@colbymchenry
colbymchenry merged commit 013b91c into main Oct 23, 2026
@colbymchenry
colbymchenry deleted the claude/issue-2499-class-expressions branch October 23, 2026 03:16
bompus added a commit to bompus/codegraph that referenced this pull request Oct 29, 2026
…ons it exposed (#582)

* fix(resolve): port upstream's lone same-file match confidence (cde4cd7)

A lone same-file definition chosen by findBestMatch scored by directory
proximity (0.7/0.4), losing to a framework's naming guess in another
file. is_decisive_same_file_match scores it 0.9 when it is the only
same-file candidate, is not the caller itself, and, as a member, belongs
to an owner the caller is inside.

Ports upstream cde4cd7 (colbymchenry#1938). same-file-match-confidence: 7/7.

* chore(resolve): dump the kernel profile at close(), not only at drop

The resolver is not dropped before process exit on the CLI index path, so
CODEGRAPH_KERNEL_PROF=1 accumulated timings that never printed. close()
is the deterministic teardown point.

* test(ts): assert the fork's native error-tree path for export type *

Upstream's kernel defers a file whose parse tree has errors, so the test
expected tryKernelExtract to return null. The fork's tsjs walker extracts
the recovered tree natively (cba9256) and keeps the re-export signature
as written — assert that contract instead.

* fix(resolve): port upstream's indexed import-path spelling (8651990)

An alias, workspace or direct-path join kept a specifier's lexical
spelling, so `@/widgets/Chart/` probed `Chart//index.tsx` and
`src/widgets/./Chart` probed `./` segments no files row is keyed by.
probe_extensions now spells each candidate as the index keys it for the
ES-module family; other languages keep the path as found.

Ports upstream 8651990 (colbymchenry#2792). import-path-spelling: 5/5.

* fix(resolve): port upstream's Dart library-privacy rule (f7820b5)

A Dart `_name` is private to its library — the library file and every
file its `part` directives name — not to its file. private_is_file_local
drops `dart`; is_visible_across_files gets the dart arm (a private
candidate is seen only from a file of its own library); and the
exact-name pre-pick filter declines a private candidate another library
declares so the caller's own library's declaration wins.

Ports upstream f7820b5 (colbymchenry#2832). dart-part-privacy: 10/12 — the two
remaining failures resolve a typed receiver's private method through
resolve_method_on_type's member path, whose visibility gate still needs
tracing (upstream's dart arm at name-matcher.ts ~13147 /
preferOwnDartLibrary is the next suspect).

* fix(resolve): vet every strategy's pick through is_visible_across_files

finish() applied name_post_guard but not the file/library-locality veto
resolveOne's nameResult gets at index.ts:1867, so typed-receiver picks
(instance-method) linked private members of another library. With the
dart arm in place this completes f7820b5: dart-part-privacy 12/12.

* fix(library): indexFiles keeps other writers out until its files are stored

The file lock was released as soon as indexing started — the promise
returned unawaited, the try ended, the finally let the lock go. Awaited,
the lock now holds until the files are stored, as indexAll and sync hold
it (upstream 865ddf4 / colbymchenry#2845).

* fix(resolve): let a framework own a reference past the name strategies

settleKernelOutcome merged kernel candidates beside the frameworks', so a
project namesake could answer a call Nuxt's navigateTo owns (upstream
58eb57a / colbymchenry#2826). With ownsReference set, the frameworks' best answer
wins or the ref stays unresolved.

* test(vue): assert the fork contract for tsx blocks — grammar always compiled in

Upstream's test asserted wasm-preload sets (9ee6718 / colbymchenry#2824); the fork
has no wasm loader, so a tsx <script> can never lack its grammar. The
block-mapping half was already fixed in sfcScriptLanguage.

* fix(resolve): finish() visibility guard on the final node, name picks only

Two corrections to the finish() is_visible_across_files port:

- Run it on the node after supertype/overload/alias retargets, the way
  upstream vets the target matchReference reports — a pre-forward object
  property or import alias is not the node upstream inspects.
- Vet only name-matcher picks: upstream's guard sits inside the
  matchReference arm, so import, file-path and framework results never
  reach it. An import pick's alias forward can legitimately land on an
  unexported module member (export const api = { run: right }).

Also ports the Rust arm upstream added for typed receivers: a method a
trait declares carries no pub of its own — reached through a typed
receiver it is the trait's (rust_trait_of + rust_typed_refs, marking
rust_written_call exits). Fixes the rust-* regressions the guard exposed
(rust-typed-receivers, rust-receiver-chains, rust-generic-bound-paths,
rust-method-value-types, rust-self-field-types, rust-wrapped-self-calls)
while keeping dart-part-privacy 12/12.

Remaining exposed failures are import-binding port debt, not guard bugs:
items$.getState().inc (import-type-modifier) and styled(Disclosure)
(function-ref-project-imports) resolve upstream through the import path
the kernel does not fully carry.

* feat(kernel): port Go value-type inference, indexed/chained/package-value call arms

Port goReceiverChainType/goElementOf/goPackageValueType semantics
tree-natively into the kernel: package-level var/const typing, indexed
and chained receiver calls, and declared-type terminal vetoes for
literals/outside types. Bound-receiver misses are terminal unless the
receiver is an asserted local the index cannot type (upstream
strategy-3 passthrough). TS gateTargetKind gains the missing upstream
arms (import self-edge, Go extends qualification, dot-imported
supertypes) and goBareTypeDir for type-position targets.

* fix(kernel): resolve Go package-value calls at typed-receiver confidence

Upstream's matchGoPackageValueCall resolves at 0.9; the arm inherited
go_method_in_package's 0.85.

* feat(kernel): Go element/field/call-result expression typing

goElementOf (named slice/map types resolve through their declarations),
goFieldTypeOf (struct field written types), selector-expression and
call-expression result arms in go_expr_written. Param/decl locals the
declaration reader misses fall back to infer_local_receiver_type.

* feat(kernel): Go chained/generic receivers, range elements, unread-file methods

* feat(kernel): Go build-constraint twins, external test packages, conversion refs (colbymchenry#2581)

Port upstream 800e582's three Go semantics into the kernel:

- A `pkg.Type(…)` conversion resolves its type through the import
  member arm — the kind filter now accepts Go exported member kinds
  (struct/interface/type_alias/variable/constant), which the TS
  edge-kind rewrite then turns into a `references` edge.
- `go_name_visible` is clause-aware: files sharing a directory but
  declaring different package clauses (`a` vs `a_test`) see each
  other's bare top-level names only through an import — qualified,
  or bare after a dot import and exported.
- New `go_build.rs` ports `goFileConstraint`/`preferGoBuildTwin`:
  `//go:build` and `// +build` expressions plus `_GOOS`/`_GOARCH`
  filename suffixes evaluate against the ordered GO_BUILD_TARGETS;
  a resolved target with constrained twins retargets to the twin
  the reference's own file builds with, and `go_pick_twin` collapses
  multi-candidate package members the import arm couldn't pick.

Also fixes the fork's `go-type-visibility.ts`: module-root packages
spell their dir `''` (matching `getGoPackageDir` and kernel
`pos_dirname`), so `goTypePositionTarget` retargets a namesake
function to the module-root type.

* feat(kernel): VB.NET namespace receivers, overload pick, head members (colbymchenry#2762)

Port upstream dbb6aa9: VbReceiver gains a namespace arm
(vb_known_namespaces/vb_namespace_around/vb_namespace_named/
vb_types_in_namespace/vb_module_member_in) so reads like
Billing.Invoice.MaxLines and Acme.Billing.Invoice.MaxLines link the
type or Module member the namespace declares; vb_takes_no_arguments +
vb_runnable_overload pick the overload VB.NET runs when a method is
named without parentheses (Me.Load, Optional/ParamArray, a ctor's
Me.New never resolves to itself); vb_head_member + vb_with_head link a
bare member before the dot (Button1.Text) when no local or parameter
shadows it, gated by foreign-Module and outside-namesake checks.
vb_receiver_type's member search is extracted as vb_member_around.

* feat(kernel): workspace package entries, path deps, manifest-edit sync (colbymchenry#2502, colbymchenry#2456)

Port e8ddc4e's declared-entry import resolution into the kernel and its
sync-side invalidation into codegraph.ts.

Kernel (napi config grows entriesByDir + scopedByName):
- resolve_workspace_import takes from_file; workspace_import_targets tries
  declared entries first — exports (exact, wildcard, fallback arrays,
  nested conditions), then source/module/main/types/typings in order —
  then an indexed direct probe, then emitted→source mapping, then the
  direct probe as last resort. Path deps (file:/link:/portal:) resolve
  scoped by the importer's nearest manifest, before global names;
  longest package name wins.
- imports.rs gains longest_package_name/match_workspace_package/
  declared_workspace_entries/indexed_target/built_source_of plus
  WorkspaceTargets/exported_targets/built_sources_of; prefilter passes
  the importing file through.

TS sync side (upstream index.ts port):
- resolver: refreshWorkspacePackages/getWorkspaceFingerprint/
  workspacePackageDirOf; a moved map closes the kernel since the config
  is construction-time.
- codegraph.ts: js_workspace_fingerprint metadata stamped at index and
  re-checked on full reconcile; a moved fingerprint re-opens every
  ESM-language ref for the orphan sweep. reopenReferencesThroughAddedFiles
  gets packageDirOf so a late-appearing declared entry re-links importers.
- loader.ts KernelWorkspaceIn + serialization gain the two new maps.

workspace-package-entries: 26/26. Regression sweep: 146/147, the one
failure a pre-existing tracked bucket (7180fd0 colbymchenry#2788).

* feat(kernel): a call on a this-field element resolves on the element's type

Port 449eefa's resolver half: `this.items[0].save()` arrives as
`this.items[].save` from the extractors (already ported) and now binds the
element type the field's declaration writes instead of bare-name matching
any project method.

- method_call_shape: elementOf arm `^this\.(#?[\w$]+)\[\]\.([\w$]+)$` →
  match_ts_this_field_call(field, method, r, element=true) — exclusive,
  like the plain `this.field.m` arm.
- TsFieldDecl gains element; ts_field_element_type reads it off the
  written type (`Item[]`, `Array<Item>`, `ReadonlyArray<Item>`,
  `Record<string, Item>`) and rejects unions, arrays of arrays and
  non-plain elements; ts_field_element adds tsFieldRead's multi-line
  continuation guard (`| Other[]` on the lines below).
- ts_field_held filters element reads through ts_class_type_parameter —
  `class Store<Item> { items: Item[] }` holds no project `Item`.
- ts_class_type_parameter ported upstream: `class|interface|type` keyword
  anchor, 24-line multi-line head, returns true when the list's `>` is
  not found (drop the type rather than take a parameter for a class).

ts-this-field-element 11/11; expression-receiver-calls +
ts-array-annotated-receivers green; receiver sweep shows only tracked
debt (08478ee colbymchenry#2811, 013b91c colbymchenry#2825); golden dumps unchanged.

* feat(kernel): calls on a typed local or parameter reach the builtin-named method (colbymchenry#2821)

A python call `reg.get()` on a builtin-named method was dropped by the
builtin filter before any strategy could read the receiver. Port
matchPythonTypedLocalCall (colbymchenry#2583) into python_attribute_verdict: a plain
local or parameter receiver settles only through scope evidence —
`python_local_class` agrees a binding def's parameter annotation (quoted,
Optional[T], Union[..., None], T | None, read off the raw def header) or
its assignments (ctor/factory/None; any foreign binding shape, rebinding
or contested evidence refuses). Members come from `python_strict_members`
— the class's own or a declared base's, resolved through the file's
imports, so a base from outside the project holds none of its methods
and the extends edges never substitute a same-name class.

Sync side: FAILED_PY_ATTR_REF widened to the one-dot `x.y` shape. The
fork's delta-narrowed retry keys (perf/sync-delta-retry) never list an
unchanged name like `get`, so a signature-only edit to the factory a
failed typed-local call reads its type from gave no retry key; the
attr-retry lane kernel-probes candidates and retries only resolvable
ones, which also lands the edge's typeFrom stamp for future edits.

* feat(kernel): a call on an unqualified call result resolves on its return type (colbymchenry#2822)

`repository().pending()` — and `val repo = repository()` locals — type the
receiver by the inner call's declared return, so `pending` is the method the
returned project type declares, never a same-named method elsewhere. A type
from outside the project leaves the name strategies untouched, and an
extension the bound-member walk can't see keeps the old name match.

The extractor's return_type keeps only a user_type's first identifier
(`Request`), so `kotlin_scoped_hit` retypes the callee through its signature
(`(): Request.Builder`) and writes a lone nested name through its declaring
outer (`Builder` → `Shop.Builder`).

Two pre-existing filters were misaligned with the kotlinCall/kotlinBare
split this relies on: member-scope reachability vetted receiver-written
names (`text().reverse`) as if receiver-less, and a Chain-shape call with a
non-project receiver type (`StringBuilder`) vetoed every name match —
upstream only constrains standard-library names there. Both now match
upstream's isReceiverLessKotlinCall / kotlinStdChain boundary.

Also: python_local_class returns Option<Answer> — a name no enclosing def
binds (module-level, global) is upstream's `undefined`, not a refused local,
which restores module-global `store = Store()` receivers the strict arm
claimed and dropped.

* feat(kernel): non-test refs resolve as if Jest manual mocks were absent (colbymchenry#2790)

Port upstream e69546e's mockless context: a ref from non-test code resolves
on a graph without the project's __mocks__/ files, while test code keeps the
whole graph. resolve_ref sets a per-ref mockless flag; nodes_by_name,
nodes_by_lower_name and nodes_by_qualified_name then drop __mocks__/ nodes
(gated on the cached mock-name sets so unaffected names aren't re-collected).
The TS callback-synthesis guards were already in place.

Also fix ts_scoped_reference's type-ref tail: upstream importedTypeMember
falls through (undefined) on a found-miss unless the specifier is outside
the repository — a resolved package directory whose exports can't be read
is not a refusal. The old gate refused references/extends refs bound to a
no-entry workspace package, which upstream answers by name-match.

* fix(sync): record files a JSX tag import reads through as synthesis inputs (colbymchenry#2563)

collectSynthesisInputs only kept files whose own content matched
mayFeedSynthesis, so a barrel or index that merely forwarded another
module's component was never recorded as an input. When a later sync
edited only that index, the JSX pass never reran and the tag kept its
stale endpoint.

Port upstream's importedTagModules: for each JSX-bearing file, map its
capitalized tags to project imports and collect every file
exportedComponent reads through, memoized per collection run.

* feat(kernel): resolve Rust calls by the receiver's written type (colbymchenry#2831)

Port upstream 8fdc8a1: a field chain or struct literal receiver's declared
type decides the call — `vis.map.get` is HashMap's, `Xyz{}.to_val` is Xyz's —
and a path call naming a type std or a dependency owns reaches only the
project's impls of that type or the named trait, never a project namesake.

- rust_expr_type types tuple-struct/enum-variant constructor calls
- undeclared-type guard limited to plain named `field_expression` heads,
  exempting generics, Self, outside types, use-aliases and wrapper-own
  methods; derived-trait provided methods resolve through `#[derive]`
- rust_path_call_reachable gates name-match on the path's outside type

Rust sweep 28 files/206 tests green; kernel golden dumps clean; the 16
remaining full-suite failures are all tracked port debt.

* feat(kernel): scope named class expressions and export them over CommonJS (colbymchenry#2825)

A named class expression is a class bound inside its expression: index
its members and supertypes, but resolve references written outside the
expression on a graph where that class and its members are not — a
same-named declaration or binding keeps its links, and `new Widget()`
elsewhere links nothing. References written inside see the whole graph
unless the name is another expression's, bound inside that one alone.

`module.exports = class Router` / `exports.Store = class StoreImpl`
are the module's value: the class stays reachable to every importer,
and collect_cjs_export records the declared name as the export's
local binding.

Inheritance refs resolved through an import binding emit upstream's
import confidence 0.9; the scoped arm's 0.95 stays for type-position
references.

* fix(kernel): a call or new never lands on an interface or a type alias (colbymchenry#2801)

Nothing calls an interface or a type alias, or makes an instance of one.
A calls/instantiates result that found a TypeScript type by name or
through an import meant the value its file declares beside it — the
function under `interface Ok` in a result module, the class merged with
an interface — and a global the project only types, like `new Response()`
or `new Worker()`, links nothing.

* fix(kernel): an explicit operator call reads its own argument list

tree-sitter-cpp parses `d.operator+=(c)` as a call on the receiver alone,
with the operator's name stranded in an ERROR sibling (`function:
(identifier) (ERROR ".operator+=") arguments: (c)`), so the callee never
spells `operator+=` and cpp_call_argument_types found no call. Every
overload then tied at 0 and the first — `operator+=(int)` — took a call
that `operator+=(const Counter&)` fits. Accept a call whose error spells
the operator name (the member-access dot is part of the error text), so
the argument types are read and the class overload wins.

`size_type` and `difference_type` count as numbers now, the container
convention upstream uses (6bd217a): nlohmann/json's `p->operator[](0)`
reaches the index overload, not the `T*` one.

* fix(kernel): a typed-local receiver keeps the invocation-time binding

The colbymchenry#2821 port (0b564c78) settled a builtin-named method call through
pythonLocalClass alone, which refuses when a name is bound more than
once. `store = A(); store = B(); store.get()` then resolved to nothing,
though the fork's receiver-scope rule has always read the binding in
effect at the call (B).

Read that binding: among plain assignments at or before the call, the
last one decides, and a bare annotation (`store: B`) does not rebind.
python_receiver_uncertain still holds back a same-line replacement and a
later replacement a closure's captured cell sees, and a later binding no
longer poisons an earlier one when the call reads before it. A def's
parameter keeps its annotation when nothing rebinds it.

Three shapes the strict read owns stay with it: a binding that is not a
plain assignment (a branch, loop, `with`, comprehension), a base from
outside the project, and a future binding read from a lambda body. A
receiver naming a class declared here (`File.write(f, "x")`) and a
lambda parameter of the receiver's name keep the ordinary paths.

* fix(resolve): vet only name picks through a module's unexported bindings

2ca95adb applied isVisibleAcrossFiles to every strategy's pick. Upstream
guards just the name match (index.ts:1867), and the port's ESM leg
vetoed picks that were never name guesses: a typed store action
(`items$.getState().inc()`) and an imported component function value
were both dropped as unexported module bindings. Keep every language's
privacy rule for a structured pick, and skip the ESM export check for a
pick a receiver's type or a function value made.

* test(eval): record the json, flask, vite and svelte precision runs

Every case held on each corpus (json 11 absent + 7 present, flask 2
present, vite 6 absent + 2 present, svelte 1 absent).

* fix(kernel): close the review findings on the three fixes

- C++ (P3): a comment inside the access (`b./* note */operator+=(a)`)
  left the comment in the error's text, so the operator name never
  matched. Compare the `operator_name` node the grammar still reads,
  and keep the trimmed-text form only when there is none.
- Python (P2): a local read before its only assignment in the same def
  (`result = store.get(); store = A()`) is an UnboundLocalError, not
  the later value; refuse it, keeping the future-initialization
  exception for a nested def that captures the outer name.
- Python (P2): two conditional bindings in different blocks leave no
  value in effect (`if flag: store = A() else: store = B()`, then
  `store.get()`); refuse. One conditional beside a `None` placeholder
  or a later plain assignment still reads, and a conflicting set whose
  binding in effect may not run stays unknown.
- ESM (P2): a function value is import-justified only when the file's
  own import resolves to the target's file, so a bare name fallback
  can no longer take an unexported namesake from another module. A
  default-exported wrapper still reaches its inner function through
  the default import, and `export default function Name` counts as an
  exported name.

Regression tests: commented operator access, a future local read, two
class-binding branches, and an imported name the module does not export.

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

JavaScript: named class expressions lack class/member structure and inheritance

1 participant