Repository navigation
fix(dispatch): require a supertype receiver for dispatch callers - #2
Merged
Merged
Conversation
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>
There was a problem hiding this comment.
🟡 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-
thisregression 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); |
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.

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 basesetupRoutes, sofind_callersforExpenseController.setupRoutesreported about 75 calls on other controllers withdispatch.via, although aBrandControllerreceiver can never be anExpenseController.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.thisinside 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
thiskeyword matches (TypeScript returns them for class searches) and inherited-member calls on sibling receivers.Validation
bun run lint,bun run typecheck: cleanvitest run tests/unit tests/integration: 203/203Sibling extends Basewiths.run()(excluded forSub.run) andthis.run()insideBase(kept). The integration test fails without the reader change.Limits or upgrade impact
🤖 Generated with Claude Code