]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: export TypeParam.Index and remove TypeParam._SetId
authorRobert Findley <rfindley@google.com>
Wed, 6 Oct 2021 17:51:21 +0000 (13:51 -0400)
committerRobert Findley <rfindley@google.com>
Tue, 12 Oct 2021 18:52:28 +0000 (18:52 +0000)
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 <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/types2/typeparam.go
src/go/types/typeparam.go

index 6bc9dbc24d5c591b986b7c5016ab453788da21bd..f7cdff0180056a7ae447661b925d345678e1e621 100644 (file)
@@ -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
 }
index e2755cbbda2040ad237d0e9748fd11bdc04590db..af36266f1180a861a42c11ced58fc31979c6d0d2 100644 (file)
@@ -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 }