Description
This proposal formally introduces the changes we've made to support parameterized functions and types in go/types
. See the full write-up here:
https://go.googlesource.com/proposal/+/master/design/47916-parameterized-go-types.md
Also see the corresponding proposal for go/ast
and go/token
: #47781.
Any feedback is appreciated. In recognition that this proposal contains a large new API surface, we will not start to evaluate whether discussion is resolved at least a few weeks. If there appears to be consensus that a change is required to the original proposal, we'll update the document and add a note here.
CC @griesemer
Changelog: (changes from the initial proposal)
TParamList
was renamed toTypeParamList
TParams
fields were renamed toTypeParams
TArgs
was renamed toTypeArgs
RParams
was renamed toRecvTypeParams
Orig
was renamed toOrigin
Info.Inferred
was renamed toInfo.Instances
, changed to use the*ast.Ident
as key, and updated to capture all type and signature instantiation.ArgumentError
was tweaked to be more idiomatic.Environment
was renamed toContext
- Setters on the
*Signature
type were replaced with a new constructor:NewSignatureType
- The
TypeParams.Index
accessor was added. Interface.IsConstraint
was replaced byInterface.IsMethodSet
.
Note: there are a few caveats/discrepancies in the current implementation. I'll keep this updated as they are resolved to coincide with the proposal.
Instantiate
will panic if passed anything other than a*Named
or*Signature
type, or with incorrect lengthtargs
. In the proposal we decided to instead make this return an error, but that is not yet done.