Go to Implementation fix for not finding type-annotated implementation#4213
Merged
Conversation
jakebailey
approved these changes
Jun 5, 2026
iisaduan
approved these changes
Jun 5, 2026
Contributor
There was a problem hiding this comment.
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
addImplementationReferencesto process a containing type-reference node on first encounter (fixing an invertedAddIfAbsentcheck). - 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. |
jakebailey
approved these changes
Jun 5, 2026
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.
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