internal/typeparams: update for recent API changes in go/types

This fixes the build when run with -tags=typeparams.

Change-Id: I94861e7f46e396804740a8e3c24f164380903a69
Reviewed-on: https://go-review.googlesource.com/c/tools/+/343129
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/internal/typeparams/typeparams.go b/internal/typeparams/typeparams.go
index 2e94210..d459b32 100644
--- a/internal/typeparams/typeparams.go
+++ b/internal/typeparams/typeparams.go
@@ -78,30 +78,31 @@
 	return tparamsSlice(named.TParams())
 }
 
-func tparamsSlice(tparams *types.TypeParams) []*types.TypeName {
-	if tparams.Len() == 0 {
+func tparamsSlice(tparams *types.TParamList) []*types.TypeName {
+	length := tparams.Len()
+	if length == 0 {
 		return nil
 	}
-	result := make([]*types.TypeName, tparams.Len())
-	for i := 0; i < tparams.Len(); i++ {
-		result[i] = tparams.At(i)
+
+	result := make([]*types.TypeName, length)
+	for i := 0; i < length; i++ {
+		result[i] = tparams.At(i).Obj()
 	}
+
 	return result
 }
 
 // NamedTArgs extracts the (possibly empty) type argument list from named.
 func NamedTArgs(named *types.Named) []types.Type {
-	ntargs := named.NumTArgs()
-	if ntargs == 0 {
-		return nil
+	targs := named.TArgs()
+	numArgs := targs.Len()
+
+	typs := make([]types.Type, numArgs)
+	for i := 0; i < numArgs; i++ {
+		typs[i] = targs.At(i)
 	}
 
-	targs := make([]types.Type, ntargs)
-	for i := 0; i < ntargs; i++ {
-		targs[i] = named.TArg(i)
-	}
-
-	return targs
+	return typs
 }
 
 // InitInferred initializes info to record inferred type information.
@@ -121,5 +122,13 @@
 		return nil, nil
 	}
 	inf := info.Inferred[e]
-	return inf.TArgs, inf.Sig
+
+	length := inf.TArgs.Len()
+
+	typs := make([]types.Type, length)
+	for i := 0; i < length; i++ {
+		typs[i] = inf.TArgs.At(i)
+	}
+
+	return typs, inf.Sig
 }