diff options
author | Robert Findley <rfindley@google.com> | 2021-08-19 13:31:36 -0400 |
---|---|---|
committer | Robert Findley <rfindley@google.com> | 2021-08-23 13:07:58 +0000 |
commit | 2438660602677b1edf5e83a1ba4fdc5dfe9e9dcc (patch) | |
tree | a03f744895bb06eb0cdf1367cf90acb50d1aa0f5 /src/go/types/typeparam.go | |
parent | 9fe5c7f12274fd4044457e863cbb8bc3ae751dcb (diff) | |
download | go-git-2438660602677b1edf5e83a1ba4fdc5dfe9e9dcc.tar.gz |
go/types: use []*TypeParam rather than []*TypeName type param lists
Making this change improves type safety slightly, and avoids many
internal type assertions.
Change-Id: I26519b0e57068e944e8243983ae90553d79e59c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/343932
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>
Diffstat (limited to 'src/go/types/typeparam.go')
-rw-r--r-- | src/go/types/typeparam.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/go/types/typeparam.go b/src/go/types/typeparam.go index 8d19d5db76..49eda1b43a 100644 --- a/src/go/types/typeparam.go +++ b/src/go/types/typeparam.go @@ -89,7 +89,7 @@ func (t *TypeParam) Underlying() Type { return t } func (t *TypeParam) String() string { return TypeString(t, nil) } // TParamList holds a list of type parameters bound to a type. -type TParamList struct{ tparams []*TypeName } +type TParamList struct{ tparams []*TypeParam } // Len returns the number of type parameters in the list. // It is safe to call on a nil receiver. @@ -98,23 +98,22 @@ func (tps *TParamList) Len() int { } // At returns the i'th type parameter in the list. -func (tps *TParamList) At(i int) *TypeName { +func (tps *TParamList) At(i int) *TypeParam { return tps.list()[i] } -func (tps *TParamList) list() []*TypeName { +func (tps *TParamList) list() []*TypeParam { if tps == nil { return nil } return tps.tparams } -func bindTParams(list []*TypeName) *TParamList { +func bindTParams(list []*TypeParam) *TParamList { if len(list) == 0 { return nil } - for i, tp := range list { - typ := tp.Type().(*TypeParam) + for i, typ := range list { if typ.index >= 0 { panic("type parameter bound more than once") } |