From 758a1a1db799319be7c0ac33d911e0e5107e48d3 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sat, 14 Aug 2021 17:57:24 +0900 Subject: [PATCH] internal/typeparams: fix undefined *types.Named.TArgs method Current tip Go runtime (7eaabae84d8b) haven't (actually removed) implements *types.Named.TArgs() method. Calculate and make targs using named.NumTArgs(). Change-Id: Ib6a61cf2f8da644f533891f9bbb30179f8a7df5c Reviewed-on: https://go-review.googlesource.com/c/tools/+/342229 Reviewed-by: Robert Findley Trust: Robert Findley Trust: Rebecca Stambler Run-TryBot: Robert Findley gopls-CI: kokoro TryBot-Result: Go Bot --- internal/typeparams/typeparams.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/typeparams/typeparams.go b/internal/typeparams/typeparams.go index be6b0525f6..2e94210246 100644 --- a/internal/typeparams/typeparams.go +++ b/internal/typeparams/typeparams.go @@ -91,7 +91,17 @@ func tparamsSlice(tparams *types.TypeParams) []*types.TypeName { // NamedTArgs extracts the (possibly empty) type argument list from named. func NamedTArgs(named *types.Named) []types.Type { - return named.TArgs() + ntargs := named.NumTArgs() + if ntargs == 0 { + return nil + } + + targs := make([]types.Type, ntargs) + for i := 0; i < ntargs; i++ { + targs[i] = named.TArg(i) + } + + return targs } // InitInferred initializes info to record inferred type information.