Skip to content

Go to Implementation fix for not finding type-annotated implementation#4213

Merged
navya9singh merged 2 commits into
mainfrom
navyasingh/VSBugFix3011057
Jun 5, 2026
Merged

Go to Implementation fix for not finding type-annotated implementation#4213
navya9singh merged 2 commits into
mainfrom
navyasingh/VSBugFix3011057

Conversation

@navya9singh
Copy link
Copy Markdown
Member

The addImplementationReferences function had an inverted condition that prevented it from finding implementations assigned via type annotations (e.g., object literals, return statements, type assertions).

The condition !state.seenContainingTypeReferences.AddIfAbsent(typeHavingNode) was incorrect — AddIfAbsent returns true when the node is newly added (first seen), so the ! caused the block to only execute for duplicates and skip first encounters entirely.

Removed the negation to match Strada's state.markSeenContainingTypeReference(typeHavingNode) semantics. Found this issue due to a bug filed in VS https://dev.azure.com/devdiv/DevDiv/_workitems/edit/3011057

Copilot AI review requested due to automatic review settings June 5, 2026 21:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a logic error in the language-service “implementations” reference collection that prevented discovering implementations introduced via type annotations (notably object literals assigned to interface-typed variables), and updates fourslash coverage/baselines accordingly.

Changes:

  • Correct addImplementationReferences to process a containing type-reference node on first encounter (fixing an inverted AddIfAbsent check).
  • Add a new fourslash test covering go-to-implementation for an interface-typed object literal assignment.
  • Update fourslash baselines to reflect newly discovered implementations (including CodeLens counts).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/ls/findallreferences.go Fixes the seen-tracking condition so type-annotated implementation expressions are actually examined and reported.
internal/fourslash/tests/goToImplementationInterfaceObjectLiteral_test.go Adds a regression fourslash test for go-to-implementation from an interface type annotation to an object literal implementation.
testdata/baselines/reference/fourslash/goToImplementation/goToImplementationInterfaceObjectLiteral.baseline.jsonc New baseline for the added go-to-implementation fourslash test.
testdata/baselines/reference/fourslash/codeLenses/codeLensInterface01.baseline.jsonc Updates CodeLens baselines to include the additional implementation found via object-literal type annotation.

@navya9singh navya9singh added this pull request to the merge queue Jun 5, 2026
Merged via the queue into main with commit 1f955e9 Jun 5, 2026
37 of 39 checks passed
@navya9singh navya9singh deleted the navyasingh/VSBugFix3011057 branch June 5, 2026 22:47
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.

4 participants