Skip to content

Fix duplicate fromRanges for method calls in call hierarchy outgoing calls - #65553

Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
microsoft:mainfrom
zhengdaodeguL:fix/call-hierarchy-dedup-65526
Open

刘亦达 (zhengdaodeguL) wants to merge 1 commit into
microsoft:mainfrom
zhengdaodeguL:fix/call-hierarchy-dedup-65526

Conversation

@zhengdaodeguL

Copy link
Copy Markdown

Fixes #65526

callHierarchy/outgoingCalls returned two identical fromRanges for a single call site such as g.m() in:

interface G { m(): void; }
function probe(g: G) { g.m(); }

Root cause: callSiteCollector.collect recorded the same call-site target twice — once in the CallExpression branch (recordCallSite(node), then recursing into node.Expression()), and again in the PropertyAccessExpression branch for the same g.m node. recordCallSite appended a range on each call, so the group produced two identical ranges.

Fix: track already-recorded targets in the collector (seenTargets set) and skip a target that has already been recorded. This dedups the same target node being visited twice, while distinct call sites (e.g. two separate baz() calls) are still recorded.

This differs from the earlier closed PR #65533, which deduped at the conversion site (slices.Compact after sorting): the collection-site fix leaves the incoming-calls path (which uses reference search, not the collector) untouched, and only suppresses genuine double-recording of the same target.

Tests: added TestOutgoingCallHierarchyDoesNotDuplicateFromRanges and TestIncomingCallHierarchyDoesNotDuplicateFromRanges in tsc/internal/lsp/server_callhierarchy_test.go. Before the fix the outgoing test failed (2 != 1); after the fix both pass. go test ./tsc/internal/lsp ./tsc/internal/ls passes; gofmt and go vet are clean.

…calls

collect() recorded the same call-site target twice for a call such as
g.m(): once in the CallExpression branch, and again when recursing
into its PropertyAccessExpression. Track already-recorded targets in
callSiteCollector so each target is recorded only once, while distinct
call sites sharing a range are preserved.

Fixes microsoft#65526
Copilot AI balanced review requested due to automatic review settings November 17, 2026 20:52
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 17, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Nov 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Duplicate callsite ranges for a single method call in callHierarchy/outgoingCalls

2 participants