From: Robert Findley Date: Wed, 6 Oct 2021 17:51:21 +0000 (-0400) Subject: go/types: export TypeParam.Index and remove TypeParam._SetId X-Git-Tag: go1.18beta1~934 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=26b6833308548f78a0926309c3acf7fd59b287f5;p=gostls13.git go/types: export TypeParam.Index and remove TypeParam._SetId This change resolves a TODO regarding a couple uncertain APIs for types.TypeParam. In the case of TypeParam._Index, we've decided it is worth exporting. In the case of TypeParam._SetId, we've decided it is unnecessary. This aligns go/types with types2 (a doc comment in types2 is also updated). Updates #47916 Change-Id: I705e8b3437d014775c473e2f8be6f32b1540bb0e Reviewed-on: https://go-review.googlesource.com/c/go/+/354370 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- diff --git a/src/cmd/compile/internal/types2/typeparam.go b/src/cmd/compile/internal/types2/typeparam.go index 6bc9dbc24d..f7cdff0180 100644 --- a/src/cmd/compile/internal/types2/typeparam.go +++ b/src/cmd/compile/internal/types2/typeparam.go @@ -50,7 +50,8 @@ func (check *Checker) newTypeParam(obj *TypeName, constraint Type) *TypeParam { return typ } -// Index returns the index of the type param within its param list. +// Index returns the index of the type param within its param list, or -1 if +// the type parameter has not yet been bound to a type. func (t *TypeParam) Index() int { return t.index } diff --git a/src/go/types/typeparam.go b/src/go/types/typeparam.go index e2755cbbda..af36266f11 100644 --- a/src/go/types/typeparam.go +++ b/src/go/types/typeparam.go @@ -50,19 +50,12 @@ func (check *Checker) newTypeParam(obj *TypeName, constraint Type) *TypeParam { return typ } -// TODO(rfindley): remove or export these placeholder APIs. - -// Index returns the index of the type param within its param list. -func (t *TypeParam) _Index() int { +// Index returns the index of the type param within its param list, or -1 if +// the type parameter has not yet been bound to a type. +func (t *TypeParam) Index() int { return t.index } -// SetId sets the unique id of a type param. Should only be used for type params -// in imported generic types. -func (t *TypeParam) _SetId(id uint64) { - t.id = id -} - // Obj returns the type name for t. func (t *TypeParam) Obj() *TypeName { return t.obj }