During the types.Alias work, there was a recurring need (7 times in x/tools; @findleyr is adding an eighth) for this interface:
package types // import "go/types"
// HasTypeName abstracts the three kinds of types that have declared names:
// aliases ([*Alias]), defined types ([*Named]), and type parameters ([*TypeParam]).
//
// Note that the Go spec considers built-in types such as string and int to
// be defined types, but this package represents them as [*Basic],
// since they do not have a declaration or [TypeName].
type HasTypeName interface {
Obj() *TypeName
}
Of course users can easily define it for themselves, but adding it to go/types provides a good place to hang additional documentation.
During the types.Alias work, there was a recurring need (7 times in x/tools; @findleyr is adding an eighth) for this interface:
Of course users can easily define it for themselves, but adding it to
go/types
provides a good place to hang additional documentation.Related:
@findleyr @griesemer