]> Cypherpunks.ru repositories - gostls13.git/commit
go/types, types2: permit partially instantiated functions as function arguments
authorRobert Griesemer <gri@golang.org>
Tue, 9 May 2023 19:38:40 +0000 (12:38 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 16 May 2023 23:01:33 +0000 (23:01 +0000)
commit099f5a985f9db17c9d1048e6afb6fd162f41256c
tree192e37b83fba33456d8593c835f0746c71dec00a
parent522be4e01000abe771362984f8d351c8452cceef
go/types, types2: permit partially instantiated functions as function arguments

This CL changes Checker.genericExprList such that it collects partially
instantiated generic functions together with their (partial) type
argument (and corresponding) expression lists, instead of trying to
infer the missing type arguments in place or to report an error.
Special care is being taken to explictly record expression types where
needed (because we can't use one of the usual expr evaluators which
takes care of that), or to track the correct instance expression for
later recording with Checker.arguments.

The resulting generic expression list is passed to Checker.arguments
which is changed to accept explicit partial type argument (and
corresponding) expression lists. The provided type arguments are fed
into type inference, matching up with their respective type parameters
(which were collected already, before this CL). If type inference is
successful, the instantiated functions are recorded as needed.

For now, the type argument expression lists are collected and passed
along but not yet used. We may use them eventually for better error
reporting.

Fixes #59958.
For #59338.

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