Repository navigation
Fix duplicate fromRanges for method calls in call hierarchy outgoing calls - #65553
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Conversation
…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
This branch has not been deployed
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.
Fixes #65526
callHierarchy/outgoingCallsreturned two identicalfromRangesfor a single call site such asg.m()in:Root cause:
callSiteCollector.collectrecorded the same call-site target twice — once in theCallExpressionbranch (recordCallSite(node), then recursing intonode.Expression()), and again in thePropertyAccessExpressionbranch for the sameg.mnode.recordCallSiteappended a range on each call, so the group produced two identical ranges.Fix: track already-recorded targets in the collector (
seenTargetsset) 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 separatebaz()calls) are still recorded.This differs from the earlier closed PR #65533, which deduped at the conversion site (
slices.Compactafter 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
TestOutgoingCallHierarchyDoesNotDuplicateFromRangesandTestIncomingCallHierarchyDoesNotDuplicateFromRangesintsc/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/lspasses;gofmtandgo vetare clean.