-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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)
TParamListwas renamed toTypeParamListTParamsfields were renamed toTypeParamsTArgswas renamed toTypeArgsRParamswas renamed toRecvTypeParamsOrigwas renamed toOriginInfo.Inferredwas renamed toInfo.Instances, changed to use the*ast.Identas key, and updated to capture all type and signature instantiation.ArgumentErrorwas tweaked to be more idiomatic.Environmentwas renamed toContext- Setters on the
*Signaturetype were replaced with a new constructor:NewSignatureType - The
TypeParams.Indexaccessor was added. Interface.IsConstraintwas 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.
Instantiatewill panic if passed anything other than a*Namedor*Signaturetype, or with incorrect lengthtargs. In the proposal we decided to instead make this return an error, but that is not yet done.