Skip to content

fix(dispatch): require a supertype receiver for dispatch callers - #2

Merged
iOwsla merged 1 commit into
mainfrom
fix/dispatch-receiver-type
Nov 3, 2026
Merged

iOwsla merged 1 commit into
mainfrom
fix/dispatch-receiver-type

Conversation

@iOwsla

@iOwsla iOwsla commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Problem and result

alpha.34 lists calls on a sibling subclass as possible dispatch callers of an override. On kiosk-software-last, CRUD controllers share a base class: brandController.setupRoutes(router) resolves to the inherited base setupRoutes, so find_callers for ExpenseController.setupRoutes reported about 75 calls on other controllers with dispatch.via, although a BrandController receiver can never be an ExpenseController.

Member call edges now record the receiver's static class/interface (metadata.receiverType). A dispatch row is kept only when that type is an ancestor of the queried member. this inside a base class, interface-typed receivers and base-typed receivers still dispatch; union, intersection and external receivers stay unrecorded and remain possible callers. The analyzer version is bumped.

The evaluation oracle now excludes this keyword matches (TypeScript returns them for class searches) and inherited-member calls on sibling receivers.

Validation

  • bun run lint, bun run typecheck: clean
  • vitest run tests/unit tests/integration: 203/203
  • Regression fixture: Sibling extends Base with s.run() (excluded for Sub.run) and this.run() inside Base (kept). The integration test fails without the reader change.

Limits or upgrade impact

  • Registered projects re-analyze once after upgrade.
  • Receiver types are recorded only for a single indexed class or interface.

🤖 Generated with Claude Code

Record the receiver's static class/interface on member call edges
(metadata receiverType). find_callers keeps a dispatch row only when that
type is an ancestor of the queried member, so calls on a sibling subclass
that merely inherits the base member are no longer listed as possible
callers of an override. Union, intersection and external receivers stay
unrecorded and remain possible callers. Bump the analyzer version.

evaluate-project: exclude `this` keyword matches and inherited-member calls
on sibling receivers from the language-service oracle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 01:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Dispatch filtering drops valid callers through last-wins deduplication and ancestry-only checks, while bracket-notation calls bypass receiver tracking and produce inconsistent results.

3 open issues
What changed in this PR

This PR narrows find_callers dispatch results using receiver-type metadata, aiming to exclude calls on sibling subclasses while preserving possible calls through base types.

Changes:

  • Records static receiver types on member-call edges and filters dispatch results by declared ancestry.
  • Updates the evaluation oracle and adds sibling-receiver and base-this regression coverage.
  • Bumps the analyzer version and documents the behavior and reindexing impact.

Source inspection was used because the project intelligence server was unavailable.

File Description
tests/​integration/​queries.test.ts Updates expected dispatch and direct callers.
tests/​fixtures/​typescript/​dispatch/​src/​service.ts Adds a sibling-typed receiver call.
tests/​fixtures/​typescript/​dispatch/​src/​handlers.ts Adds a sibling subclass and base-this call.
scripts/​evaluate-project.ts Excludes this matches and filters inherited-member references.
packages/​plugin-typescript/​src/​index.ts Records receiver metadata and bumps the analyzer version.
packages/​database/​src/​reader.ts Filters dispatch callers using receiver ancestry.
docs/​graph.md Documents receiver-aware dispatch filtering.
CHANGELOG.md Records the changes and reanalysis requirement.

Review effort: Balanced

Comment on lines +215 to +216
AND (e.data#>>'{metadata,receiverType}' IS NULL
OR e.data#>>'{metadata,receiverType}' IN (SELECT id FROM supers)))
Comment on lines +482 to +486
const metadata = !ts.isPropertyAccessExpression(callee)
? undefined
: callee.expression.kind === ts.SyntaxKind.SuperKeyword
? { receiver: "super" }
: receiverType(callee.expression);
"SEMANTIC_CONFIRMED",
nonvirtual ? { receiver: "super" } : undefined,
);
addEdge(callOwner, target, "CALLS", lineOf(node), "SEMANTIC_CONFIRMED", metadata);
@iOwsla
iOwsla merged commit 0995730 into main Nov 3, 2026
4 checks passed
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