-
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: fix signatureHelp with pointer receivers
I just ran into this today. Alas, it took us too long to fix this. Fixes golang/go#61189 Change-Id: Iac28a6ba30d099cb2bb6f9d761ee658e190aa07c Reviewed-on: https://go-review.googlesource.com/c/tools/+/539677 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
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
21 changes: 21 additions & 0 deletions
21
gopls/internal/regtest/marker/testdata/signature/generic.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,21 @@ | ||
This test checks signature help on generic signatures. | ||
|
||
-- g.go -- | ||
package g | ||
|
||
type M[K comparable, V any] map[K]V | ||
|
||
// golang/go#61189: signatureHelp must handle pointer receivers. | ||
func (m *M[K, V]) Get(k K) V { | ||
return (*m)[k] | ||
} | ||
|
||
func Get[K comparable, V any](m M[K, V], k K) V { | ||
return m[k] | ||
} | ||
|
||
func _() { | ||
var m M[int, string] | ||
_ = m.Get(0) //@signature("(", "Get(k int) string", 0) | ||
_ = Get(m, 0) //@signature("0", "Get(m M[int, string], k int) string", 1) | ||
} |