diff options
author | Rob Findley <rfindley@google.com> | 2021-08-04 10:43:08 -0400 |
---|---|---|
committer | Robert Findley <rfindley@google.com> | 2021-08-04 23:23:45 +0000 |
commit | 0ec2a8b42d1aa94629ffebdb8f501435cfd14980 (patch) | |
tree | 191d81736098c1d598ffa4b2a9dd1d06cef197fc | |
parent | e5fe769be15e60a1f4626cf30fb1f560cb9f317f (diff) | |
download | go-0ec2a8b42d1aa94629ffebdb8f501435cfd14980.tar.gz go-0ec2a8b42d1aa94629ffebdb8f501435cfd14980.zip |
[dev.typeparams] go/types: switch the TArgs API to NumTArgs/TArg
As with other go/types APIs, we should not expose the underlying
Named.targs slice.
Change-Id: Iba869298fbd3856022ffe8ec2c3273341598c324
Reviewed-on: https://go-review.googlesource.com/c/go/+/340009
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>
-rw-r--r-- | src/go/types/named.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/go/types/named.go b/src/go/types/named.go index fc53783ab8..f26b50aa81 100644 --- a/src/go/types/named.go +++ b/src/go/types/named.go @@ -125,8 +125,12 @@ func (t *Named) TParams() *TypeParams { return t.load().tparams } // SetTParams sets the type parameters of the named type t. func (t *Named) SetTParams(tparams []*TypeName) { t.load().tparams = bindTParams(tparams) } -// TArgs returns the type arguments after instantiation of the named type t, or nil if not instantiated. -func (t *Named) TArgs() []Type { return t.targs } +// NumTArgs returns the number of type arguments used to instantiate the named +// type t, or 0 if t is not an instantiated type. +func (t *Named) NumTArgs() int { return len(t.targs) } + +// TArgs returns the i'th type argument of the named type t for 0 <= i < t.NumTArgs(). +func (t *Named) TArg(i int) Type { return t.targs[i] } // SetTArgs sets the type arguments of the named type t. func (t *Named) SetTArgs(args []Type) { t.targs = args } |