-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/lsp/source: reinstate equalOrigin for references check
This logic was dropped in CL 464902, but is necessary for correctly resolving references to variables. Fixes golang/go#61618 Change-Id: Iebe46339e5f6ac0230f7376e742d786bae2a7438 Reviewed-on: https://go-review.googlesource.com/c/tools/+/513780 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
- Loading branch information
Showing
2 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
39 changes: 39 additions & 0 deletions
39
gopls/internal/regtest/marker/testdata/references/issue61618.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Regression test for 'references' bug golang/go#61618: | ||
references to instantiated fields were missing. | ||
|
||
-- flags -- | ||
-min_go=go1.18 | ||
|
||
-- go.mod -- | ||
module example.com | ||
go 1.18 | ||
|
||
-- a.go -- | ||
package a | ||
|
||
// This file is adapted from the example in the issue. | ||
|
||
type builder[S ~[]F, F ~string] struct { | ||
name string | ||
elements S //@loc(def, "elements"), refs(def, def, assign, use) | ||
elemData map[F][]ElemData[F] | ||
} | ||
|
||
type ElemData[F ~string] struct { | ||
Name F | ||
} | ||
|
||
type BuilderImpl[S ~[]F, F ~string] struct{ builder[S, F] } | ||
|
||
func NewBuilderImpl[S ~[]F, F ~string](name string) *BuilderImpl[S, F] { | ||
impl := &BuilderImpl[S,F]{ | ||
builder[S, F]{ | ||
name: name, | ||
elements: S{}, //@loc(assign, "elements"), refs(assign, def, assign, use) | ||
elemData: map[F][]ElemData[F]{}, | ||
}, | ||
} | ||
|
||
_ = impl.elements //@loc(use, "elements"), refs(use, def, assign, use) | ||
return impl | ||
} |