]> Cypherpunks.ru repositories - gostls13.git/commit
go/types, types2: rename generic function arguments
authorRobert Griesemer <gri@golang.org>
Thu, 4 May 2023 00:47:29 +0000 (17:47 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 4 May 2023 17:01:49 +0000 (17:01 +0000)
commit8337ca094beb07001cba12a1f88926dff78c1bcd
tree8511b6b67376de4412a70e20025522413274a9a3
parent8dea63547035e2246e09ba96d0338ad9ba8b39ad
go/types, types2: rename generic function arguments

For correct inference, if the same generic function is provided
more than once as an argument to another function, the argument
function's type parameters must be unique for each argument so
that the type parameters can be correctly inferred.

Example:

func f(func(int), func(string)) {}

func g[P any](P) {}

func _() {
f(g, g)
}

Here the type parameter P for the first g argument resolves to int
and the type parameter P for the second g argument resolves to string.

Fixes #59956.
For #59338.

Change-Id: I10ce0ea08c2033722dd7c7c976b2a5448b2ee2d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/492516
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/call.go
src/go/types/api_test.go
src/go/types/call.go
src/internal/types/testdata/examples/inference2.go
src/internal/types/testdata/fixedbugs/issue59956.go [new file with mode: 0644]