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 Basic.Obj #71886

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

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.
Milestone

Comments

@adonovan
Copy link
Member

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:

// 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
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.
Projects
None yet
Development

No branches or pull requests

3 participants