Skip to content
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

x/tools/gopls: rank type names better when instantiating generic types #51782

Closed
muirdm opened this issue Mar 18, 2022 · 1 comment
Closed

x/tools/gopls: rank type names better when instantiating generic types #51782

muirdm opened this issue Mar 18, 2022 · 1 comment
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@muirdm
Copy link

muirdm commented Mar 18, 2022

func foo[T float64 | int](a T) T {
	return a
}

func main() {
	foo[<>](a T)
}

When completing at <> we don't currently even prefer type names, let alone preferring types that match the constraint.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 18, 2022
@gopherbot gopherbot added this to the Unreleased milestone Mar 18, 2022
@suzmue suzmue modified the milestones: Unreleased, gopls/on-deck Mar 18, 2022
@gopherbot
Copy link

Change https://go.dev/cl/394014 mentions this issue: lsp/completion: improve completion for func type params

@findleyr findleyr modified the milestones: gopls/on-deck, gopls/v0.8.2 Mar 22, 2022
gopherbot pushed a commit to golang/tools that referenced this issue Mar 22, 2022
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>
@findleyr findleyr modified the milestones: gopls/v0.8.2, gopls/v0.8.3 Mar 31, 2022
@muirdm muirdm closed this as completed Apr 2, 2022
@golang golang locked and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants