Skip to content

proposal: go/types: add Basic.Obj #71886

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

Open
adonovan opened this issue Feb 21, 2025 · 1 comment
Open

proposal: go/types: add Basic.Obj #71886

adonovan opened this issue Feb 21, 2025 · 1 comment
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Feb 21, 2025

A types.Basic has a name (TypeName). For consistency, it should have an Obj() method, like Alias, Named, and TypeParam.

 package types

+ // Obj returns the type name for the built-in declaration defining the basic type b.
+ func (b *Basic) Obj() *TypeName { return Universe.Lookup(b.name).(*TypeName) }

Context: https://go.dev/cl/650755

Perhaps we should also add this interface (this is existing proposal #66890):

// A TypeWithName is a [Type] with a name ([TypeName]).
// It is implemented by [*Alias], [*Basic], [*Named], and [*TypeParam].
type TypeWithName interface {
       Type
       Obj() *TypeName
}

@griesemer @jba @findleyr

@gabyhelp
Copy link

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@gabyhelp gabyhelp added the LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool label Feb 21, 2025
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 21, 2025
@mknyszek mknyszek added this to the Backlog milestone Feb 21, 2025
@mknyszek mknyszek added the FeatureRequest Issues asking for a new feature that does not need a proposal. label Feb 21, 2025
@adonovan adonovan changed the title go/types: add Basic.Obj proposal: go/types: add Basic.Obj Apr 7, 2025
@adonovan adonovan moved this to Incoming in Proposals Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal
Projects
Status: Incoming
Development

No branches or pull requests

4 participants