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

go/types: add Alias parameter methods #67143

Closed
griesemer opened this issue May 2, 2024 · 4 comments
Closed

go/types: add Alias parameter methods #67143

griesemer opened this issue May 2, 2024 · 4 comments

Comments

@griesemer
Copy link
Contributor

For the purposes of generic Alias types we propose the following additional API.
As with other generic types, instances are created with types.Instantiate.
These methods match the corresponding methods for Named types.

package types

// TypeParams returns the type parameters of the alias type a, or nil.
// A generic Alias and its instances have the same type parameters.
func (a *Alias) TypeParams() *TypeParamList

// SetTypeParams sets the type parameters of the alias type a.
// a must not have type arguments.
func (a *Alias) SetTypeParams(tparams []*TypeParam)

// TypeArgs returns the type arguments used to instantiate the Alias type.
// If a is not an instance of a generic alias, the result is nil.
func (a *Alias) TypeArgs() *TypeList

// Origin returns the generic Alias type of which a is an instance.
// If a is not an instance of a generic alias, Origin returns a.
func (a *Alias) Origin() *Alias
@griesemer griesemer added this to the Go1.23 milestone May 2, 2024
@griesemer griesemer self-assigned this May 2, 2024
@adonovan adonovan moved this to Incoming in Proposals May 2, 2024
@ianlancetaylor ianlancetaylor changed the title Proposal: go/types: add Alias.{TypeParams, SetTypeParams, TypeArgs, Origin} proposal: go/types: add Alias.{TypeParams, SetTypeParams, TypeArgs, Origin} May 2, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/583757 mentions this issue: go/types, types2: add Alias.{TypeParams, SetTypeParams, TypeArgs, Origin}

@rsc
Copy link
Contributor

rsc commented May 8, 2024

These are the same methods that types.Named already has, so this seems fine.

@rsc rsc changed the title proposal: go/types: add Alias.{TypeParams, SetTypeParams, TypeArgs, Origin} proposal: go/types: add Alias parameter methods May 8, 2024
@rsc
Copy link
Contributor

rsc commented May 8, 2024

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

The proposal is #67143 (comment).

@rsc rsc moved this from Incoming to Likely Accept in Proposals May 8, 2024
@rsc
Copy link
Contributor

rsc commented May 15, 2024

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

The proposal is #67143 (comment).

@rsc rsc moved this from Likely Accept to Accepted in Proposals May 15, 2024
@rsc rsc changed the title proposal: go/types: add Alias parameter methods go/types: add Alias parameter methods May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Accepted
Development

No branches or pull requests

3 participants