-
Notifications
You must be signed in to change notification settings - Fork 2.3k
gopls/internal/golang/completion: don't make unnecessary conversions for generic functions #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gopls/internal/golang/completion: don't make unnecessary conversions for generic functions #584
Conversation
This PR (HEAD: ee94a82) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/692815. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Nikita Shoshin: Patch Set 1: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from t hepudds: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from t hepudds: Patch Set 2: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 2: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-08-07T23:01:40Z","revision":"7cd7227869a1680f977c052b516009d68c85a548"} Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 2: LUCI-TryBot-Result-1 Copied votes on follow-up patch sets have been updated:
Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 3: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-08-07T23:17:35Z","revision":"05e326dc012e7ab0e99c690396602a3ff98a9615"} Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Nikita Shoshin: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from t hepudds: Patch Set 3: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 3: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 3: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Robert Findley: Patch Set 3: (4 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
ee94a82
to
02bb3f8
Compare
This PR (HEAD: 02bb3f8) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/692815. Important tips:
|
Message from Nikita Shoshin: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Robert Findley: Patch Set 4: Auto-Submit+1 Code-Review+2 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 4: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-08-08T15:26:18Z","revision":"66f778e277271bdc3883068b7d8ef4517a5fa8bf"} Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Robert Findley: Patch Set 4: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 4: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 4: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Alan Donovan: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
…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)) }) } ```
02bb3f8
to
277fca7
Compare
This PR (HEAD: 277fca7) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/692815. Important tips:
|
Message from Nikita Shoshin: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Alan Donovan: Patch Set 5: Code-Review+2 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Robert Findley: Patch Set 5: Auto-Submit+1 Code-Review+1 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
Message from Go LUCI: Patch Set 5: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-08-08T21:41:56Z","revision":"d0c4149afdb24359f6c5becd556a8bb8377c98cc"} Please don’t reply on this GitHub thread. Visit golang.org/cl/692815. |
…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>
This PR is being closed because golang.org/cl/692815 has been merged. |
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: