Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lsp/completion: improve completion for func type params
Now when instantiating a generic function, we prefer type names that are assignable to the corresponding constraint. For example: func foo[A int|string]() {} foo[<>]() At <> we prefer the type names "int" and "string". Previously we had no preference at all. Updates golang/go#51782. Change-Id: I7ed39ffa2bc4c63e9d320f47a58e139251712bb3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/394014 Run-TryBot: Muir Manders <muir@mnd.rs> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
- Loading branch information
Showing
3 changed files
with
34 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
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
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,13 @@ | ||
//go:build go1.18 | ||
// +build go1.18 | ||
|
||
package typeparams | ||
|
||
func one[a int | string]() {} | ||
func two[a int | string, b float64 | int]() {} | ||
|
||
func _() { | ||
one[]() //@rank("]", string, float64) | ||
two[]() //@rank("]", int, float64) | ||
two[int, f]() //@rank("]", float64, float32) | ||
} |