Commit 8866876
gopls/internal/golang/completion: don't make unnecessary conversions for generic functions
Type conversions introduced by CL 618675 are necessary only when
function results are generic (e.g. "func New[T any](v ...T) Set[T]").
This CL adds an additional check to prevent unnecessary conversions.
It also fixes cases where accepting a completion item would result
in a compile error, like this:
func sort(s []int) {
slices.SortFunc(s, func(a, b int) int {
// compile error: cannot use interface cmp.Ordered in conversion
return cmp.Compare(cmp.Ordered(a))
})
}
Change-Id: I469c60883de470b7bf4ed292dbadbb76255d5778
GitHub-Last-Rev: 277fca7
GitHub-Pull-Request: #584
Reviewed-on: https://go-review.googlesource.com/c/tools/+/692815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>1 parent 9c0760d commit 8866876
File tree
3 files changed
+84
-1
lines changed- gopls/internal
- golang
- completion
- test/marker/testdata/completion
3 files changed
+84
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2419 | 2419 | | |
2420 | 2420 | | |
2421 | 2421 | | |
2422 | | - | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
2423 | 2425 | | |
2424 | 2426 | | |
2425 | 2427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
773 | 773 | | |
774 | 774 | | |
775 | 775 | | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
776 | 779 | | |
777 | 780 | | |
778 | 781 | | |
| |||
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments