go/internal/gcimporter: allow both prefixes and subscripts for tparams

Add some flexibility to the gcimporter while we work on adjusting the
compiler to identify type parameters with a path prefix, rather than a
numeric subscript.

Change-Id: Ia9d5b0d3daebf31b9181dce5127da637d40510ba
Reviewed-on: https://go-review.googlesource.com/c/tools/+/353410
Trust: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
diff --git a/go/internal/gcimporter/iimport.go b/go/internal/gcimporter/iimport.go
index 0c56eb2..8843db0 100644
--- a/go/internal/gcimporter/iimport.go
+++ b/go/internal/gcimporter/iimport.go
@@ -18,6 +18,7 @@
 	"go/types"
 	"io"
 	"sort"
+	"strings"
 
 	"golang.org/x/tools/internal/typeparams"
 )
@@ -405,12 +406,21 @@
 		if r.p.exportVersion < iexportVersionGenerics {
 			errorf("unexpected type param type")
 		}
-		name0, sub := parseSubscript(name)
+		// Temporarily strip both type parameter subscripts and path prefixes,
+		// while we replace subscripts with prefixes in the compiler.
+		// TODO(rfindley): remove support for subscripts once the compiler changes
+		// have landed.
+		name0, _ := parseSubscript(name)
+		ix := strings.LastIndex(name, ".")
+		name0 = name0[ix+1:]
 		tn := types.NewTypeName(pos, r.currPkg, name0, nil)
 		t := typeparams.NewTypeParam(tn, nil)
-		if sub == 0 {
-			errorf("name %q missing subscript", name)
-		}
+
+		// The check below is disabled so that we can support both path-prefixed
+		// and subscripted type parameter names.
+		// if sub == 0 {
+		// 	errorf("name %q missing subscript", name)
+		// }
 
 		// TODO(rfindley): can we use a different, stable ID?
 		// t.SetId(sub)