Skip to content

Conversation

@ShoshinNikita
Copy link
Contributor

@ShoshinNikita ShoshinNikita commented Aug 2, 2025

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))
	})
}
@gopherbot
Copy link
Contributor

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:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Nikita Shoshin:

Patch Set 1:

(3 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from t hepudds:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from t hepudds:

Patch Set 2: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 2: LUCI-TryBot-Result-1

Copied votes on follow-up patch sets have been updated:

  • LUCI-TryBot-Result-1 has been copied to patch set 3 (copy condition: "changekind:NO_CODE_CHANGE").

Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Nikita Shoshin:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from t hepudds:

Patch Set 3: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 3: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Robert Findley:

Patch Set 3:

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@ShoshinNikita ShoshinNikita force-pushed the remove-unnecessary-conversions branch from ee94a82 to 02bb3f8 Compare August 8, 2025 14:58
@gopherbot
Copy link
Contributor

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:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Nikita Shoshin:

Patch Set 4:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Robert Findley:

Patch Set 4: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 4: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Alan Donovan:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

…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))
	})
}
```
@ShoshinNikita ShoshinNikita force-pushed the remove-unnecessary-conversions branch from 02bb3f8 to 277fca7 Compare August 8, 2025 17:12
@gopherbot
Copy link
Contributor

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:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Nikita Shoshin:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/692815.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

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.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Aug 8, 2025
…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>
@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/692815 has been merged.

@gopherbot gopherbot closed this Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants