internal/typeparams: eliminate type aliases

Change-Id: I660520bbb1dae855e52bf92492045bb3b16eff8d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/549119
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/go/analysis/passes/composite/composite.go b/go/analysis/passes/composite/composite.go
index c7a4977..847063b 100644
--- a/go/analysis/passes/composite/composite.go
+++ b/go/analysis/passes/composite/composite.go
@@ -72,7 +72,7 @@
 		}
 		var structuralTypes []types.Type
 		switch typ := typ.(type) {
-		case *typeparams.TypeParam:
+		case *types.TypeParam:
 			terms, err := typeparams.StructuralTerms(typ)
 			if err != nil {
 				return // invalid type
@@ -163,7 +163,7 @@
 	case *types.Named:
 		// names in package foo are local to foo_test too
 		return strings.TrimSuffix(x.Obj().Pkg().Path(), "_test") == strings.TrimSuffix(pass.Pkg.Path(), "_test")
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		return strings.TrimSuffix(x.Obj().Pkg().Path(), "_test") == strings.TrimSuffix(pass.Pkg.Path(), "_test")
 	}
 	return false
diff --git a/go/analysis/passes/copylock/copylock.go b/go/analysis/passes/copylock/copylock.go
index 2eeb0a3..6cbbc7e 100644
--- a/go/analysis/passes/copylock/copylock.go
+++ b/go/analysis/passes/copylock/copylock.go
@@ -255,7 +255,7 @@
 	}
 	seen[typ] = true
 
-	if tpar, ok := typ.(*typeparams.TypeParam); ok {
+	if tpar, ok := typ.(*types.TypeParam); ok {
 		terms, err := typeparams.StructuralTerms(tpar)
 		if err != nil {
 			return nil // invalid type
diff --git a/go/analysis/passes/ifaceassert/parameterized.go b/go/analysis/passes/ifaceassert/parameterized.go
index b84577f..1fdd30c 100644
--- a/go/analysis/passes/ifaceassert/parameterized.go
+++ b/go/analysis/passes/ifaceassert/parameterized.go
@@ -102,7 +102,7 @@
 			}
 		}
 
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		return true
 
 	default:
diff --git a/go/analysis/passes/nilfunc/nilfunc.go b/go/analysis/passes/nilfunc/nilfunc.go
index 6df1343..778f7f1 100644
--- a/go/analysis/passes/nilfunc/nilfunc.go
+++ b/go/analysis/passes/nilfunc/nilfunc.go
@@ -62,7 +62,7 @@
 			obj = pass.TypesInfo.Uses[v]
 		case *ast.SelectorExpr:
 			obj = pass.TypesInfo.Uses[v.Sel]
-		case *ast.IndexExpr, *typeparams.IndexListExpr:
+		case *ast.IndexExpr, *ast.IndexListExpr:
 			// Check generic functions such as "f[T1,T2]".
 			x, _, _, _ := typeparams.UnpackIndexExpr(v)
 			if id, ok := x.(*ast.Ident); ok {
diff --git a/go/analysis/passes/printf/types.go b/go/analysis/passes/printf/types.go
index 7cbb0bd..ab98e56 100644
--- a/go/analysis/passes/printf/types.go
+++ b/go/analysis/passes/printf/types.go
@@ -72,7 +72,7 @@
 		return true
 	}
 
-	if typ, _ := typ.(*typeparams.TypeParam); typ != nil {
+	if typ, _ := typ.(*types.TypeParam); typ != nil {
 		// Avoid infinite recursion through type parameters.
 		if m.seen[typ] {
 			return true
diff --git a/go/analysis/passes/shift/shift.go b/go/analysis/passes/shift/shift.go
index bafb911..e272df7 100644
--- a/go/analysis/passes/shift/shift.go
+++ b/go/analysis/passes/shift/shift.go
@@ -99,7 +99,7 @@
 	}
 	var structuralTypes []types.Type
 	switch t := t.(type) {
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		terms, err := typeparams.StructuralTerms(t)
 		if err != nil {
 			return // invalid type
diff --git a/go/analysis/passes/stringintconv/string.go b/go/analysis/passes/stringintconv/string.go
index bb04dae..b2591cc 100644
--- a/go/analysis/passes/stringintconv/string.go
+++ b/go/analysis/passes/stringintconv/string.go
@@ -195,7 +195,7 @@
 func structuralTypes(t types.Type) ([]types.Type, error) {
 	var structuralTypes []types.Type
 	switch t := t.(type) {
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		terms, err := typeparams.StructuralTerms(t)
 		if err != nil {
 			return nil, err
diff --git a/go/analysis/passes/testinggoroutine/util.go b/go/analysis/passes/testinggoroutine/util.go
index 805ccf4..d156851 100644
--- a/go/analysis/passes/testinggoroutine/util.go
+++ b/go/analysis/passes/testinggoroutine/util.go
@@ -57,7 +57,7 @@
 
 func funcIdent(fun ast.Expr) *ast.Ident {
 	switch fun := astutil.Unparen(fun).(type) {
-	case *ast.IndexExpr, *typeparams.IndexListExpr:
+	case *ast.IndexExpr, *ast.IndexListExpr:
 		x, _, _, _ := typeparams.UnpackIndexExpr(fun) // necessary?
 		id, _ := x.(*ast.Ident)
 		return id
diff --git a/go/analysis/passes/unmarshal/unmarshal.go b/go/analysis/passes/unmarshal/unmarshal.go
index 7043baa..f4e7352 100644
--- a/go/analysis/passes/unmarshal/unmarshal.go
+++ b/go/analysis/passes/unmarshal/unmarshal.go
@@ -14,7 +14,6 @@
 	"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
 	"golang.org/x/tools/go/ast/inspector"
 	"golang.org/x/tools/go/types/typeutil"
-	"golang.org/x/tools/internal/typeparams"
 )
 
 //go:embed doc.go
@@ -92,7 +91,7 @@
 
 		t := pass.TypesInfo.Types[call.Args[argidx]].Type
 		switch t.Underlying().(type) {
-		case *types.Pointer, *types.Interface, *typeparams.TypeParam:
+		case *types.Pointer, *types.Interface, *types.TypeParam:
 			return
 		}
 
diff --git a/go/ast/astutil/enclosing.go b/go/ast/astutil/enclosing.go
index 9fa5aa1..c05873a 100644
--- a/go/ast/astutil/enclosing.go
+++ b/go/ast/astutil/enclosing.go
@@ -377,7 +377,7 @@
 			tok(n.Lbrack, len("[")),
 			tok(n.Rbrack, len("]")))
 
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		children = append(children,
 			tok(n.Lbrack, len("[")),
 			tok(n.Rbrack, len("]")))
@@ -588,7 +588,7 @@
 		return "decrement statement"
 	case *ast.IndexExpr:
 		return "index expression"
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		return "index list expression"
 	case *ast.InterfaceType:
 		return "interface type"
diff --git a/go/ast/astutil/rewrite.go b/go/ast/astutil/rewrite.go
index f430b21..94bc887 100644
--- a/go/ast/astutil/rewrite.go
+++ b/go/ast/astutil/rewrite.go
@@ -252,7 +252,7 @@
 		a.apply(n, "X", nil, n.X)
 		a.apply(n, "Index", nil, n.Index)
 
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		a.apply(n, "X", nil, n.X)
 		a.applyList(n, "Indices")
 
diff --git a/go/ast/inspector/inspector_test.go b/go/ast/inspector/inspector_test.go
index 4b26ff6..57a2293 100644
--- a/go/ast/inspector/inspector_test.go
+++ b/go/ast/inspector/inspector_test.go
@@ -17,7 +17,6 @@
 	"testing"
 
 	"golang.org/x/tools/go/ast/inspector"
-	"golang.org/x/tools/internal/typeparams"
 )
 
 var netFiles []*ast.File
@@ -94,7 +93,7 @@
 	inspect := inspector.New([]*ast.File{f})
 	found := make([]bool, 16)
 
-	indexListExprs := make(map[*typeparams.IndexListExpr]bool)
+	indexListExprs := make(map[*ast.IndexListExpr]bool)
 
 	// Verify that we reach all i* identifiers, and collect IndexListExpr nodes.
 	inspect.Preorder(nil, func(n ast.Node) {
@@ -107,7 +106,7 @@
 				}
 				found[index] = true
 			}
-		case *typeparams.IndexListExpr:
+		case *ast.IndexListExpr:
 			indexListExprs[n] = false
 		}
 	})
@@ -122,8 +121,8 @@
 	if len(indexListExprs) == 0 {
 		t.Fatal("no index list exprs found")
 	}
-	inspect.Preorder([]ast.Node{&typeparams.IndexListExpr{}}, func(n ast.Node) {
-		ix := n.(*typeparams.IndexListExpr)
+	inspect.Preorder([]ast.Node{&ast.IndexListExpr{}}, func(n ast.Node) {
+		ix := n.(*ast.IndexListExpr)
 		indexListExprs[ix] = true
 	})
 	for ix, v := range indexListExprs {
diff --git a/go/ast/inspector/typeof.go b/go/ast/inspector/typeof.go
index 703c813..2a872f8 100644
--- a/go/ast/inspector/typeof.go
+++ b/go/ast/inspector/typeof.go
@@ -12,8 +12,6 @@
 import (
 	"go/ast"
 	"math"
-
-	"golang.org/x/tools/internal/typeparams"
 )
 
 const (
@@ -171,7 +169,7 @@
 		return 1 << nIncDecStmt
 	case *ast.IndexExpr:
 		return 1 << nIndexExpr
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		return 1 << nIndexListExpr
 	case *ast.InterfaceType:
 		return 1 << nInterfaceType
diff --git a/go/callgraph/vta/graph.go b/go/callgraph/vta/graph.go
index 4d1d525..987859c 100644
--- a/go/callgraph/vta/graph.go
+++ b/go/callgraph/vta/graph.go
@@ -661,14 +661,14 @@
 func (b *builder) multiconvert(c *ssa.MultiConvert) {
 	// TODO(zpavlinovic): decide what to do on MultiConvert long term.
 	// TODO(zpavlinovic): add unit tests.
-	typeSetOf := func(typ types.Type) []*typeparams.Term {
+	typeSetOf := func(typ types.Type) []*types.Term {
 		// This is a adaptation of x/exp/typeparams.NormalTerms which x/tools cannot depend on.
-		var terms []*typeparams.Term
+		var terms []*types.Term
 		var err error
 		switch typ := typ.(type) {
-		case *typeparams.TypeParam:
+		case *types.TypeParam:
 			terms, err = typeparams.StructuralTerms(typ)
-		case *typeparams.Union:
+		case *types.Union:
 			terms, err = typeparams.UnionTermSet(typ)
 		case *types.Interface:
 			terms, err = typeparams.InterfaceTermSet(typ)
@@ -676,7 +676,7 @@
 			// Common case.
 			// Specializing the len=1 case to avoid a slice
 			// had no measurable space/time benefit.
-			terms = []*typeparams.Term{typeparams.NewTerm(false, typ)}
+			terms = []*types.Term{typeparams.NewTerm(false, typ)}
 		}
 
 		if err != nil {
diff --git a/go/ssa/builder.go b/go/ssa/builder.go
index 92465b8..0d6716c 100644
--- a/go/ssa/builder.go
+++ b/go/ssa/builder.go
@@ -802,7 +802,7 @@
 			if types.IsInterface(rt) {
 				// If v may be an interface type I (after instantiating),
 				// we must emit a check that v is non-nil.
-				if recv, ok := sel.recv.(*typeparams.TypeParam); ok {
+				if recv, ok := sel.recv.(*types.TypeParam); ok {
 					// Emit a nil check if any possible instantiation of the
 					// type parameter is an interface type.
 					if typeSetOf(recv).Len() > 0 {
@@ -848,7 +848,7 @@
 
 		panic("unexpected expression-relative selector")
 
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		// f[X, Y] must be a generic function
 		if !instance(fn.info, e.X) {
 			panic("unexpected expression-could not match index list to instantiation")
diff --git a/go/ssa/const.go b/go/ssa/const.go
index 4a51a2c..2a6ac58 100644
--- a/go/ssa/const.go
+++ b/go/ssa/const.go
@@ -125,7 +125,7 @@
 			components[i] = zeroString(t.At(i).Type(), from)
 		}
 		return "(" + strings.Join(components, ", ") + ")"
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		return "*new(" + relType(t, from) + ")"
 	}
 	panic(fmt.Sprint("zeroString: unexpected ", t))
diff --git a/go/ssa/coretype.go b/go/ssa/coretype.go
index 128d61e..957696b 100644
--- a/go/ssa/coretype.go
+++ b/go/ssa/coretype.go
@@ -40,19 +40,19 @@
 }
 
 // termList is a list of types.
-type termList []*typeparams.Term       // type terms of the type set
+type termList []*types.Term            // type terms of the type set
 func (s termList) Len() int            { return len(s) }
 func (s termList) At(i int) types.Type { return s[i].Type() }
 
 // typeSetOf returns the type set of typ. Returns an empty typeset on an error.
 func typeSetOf(typ types.Type) termList {
 	// This is a adaptation of x/exp/typeparams.NormalTerms which x/tools cannot depend on.
-	var terms []*typeparams.Term
+	var terms []*types.Term
 	var err error
 	switch typ := typ.(type) {
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		terms, err = typeparams.StructuralTerms(typ)
-	case *typeparams.Union:
+	case *types.Union:
 		terms, err = typeparams.UnionTermSet(typ)
 	case *types.Interface:
 		terms, err = typeparams.InterfaceTermSet(typ)
@@ -60,7 +60,7 @@
 		// Common case.
 		// Specializing the len=1 case to avoid a slice
 		// had no measurable space/time benefit.
-		terms = []*typeparams.Term{typeparams.NewTerm(false, typ)}
+		terms = []*types.Term{typeparams.NewTerm(false, typ)}
 	}
 
 	if err != nil {
diff --git a/go/ssa/create.go b/go/ssa/create.go
index 653ce2e..c5f952d 100644
--- a/go/ssa/create.go
+++ b/go/ssa/create.go
@@ -117,7 +117,7 @@
 	sig := obj.Type().(*types.Signature)
 
 	// Collect type parameters.
-	var tparams *typeparams.TypeParamList
+	var tparams *types.TypeParamList
 	if rtparams := typeparams.RecvTypeParams(sig); rtparams.Len() > 0 {
 		tparams = rtparams // method of generic type
 	} else if sigparams := typeparams.ForSignature(sig); sigparams.Len() > 0 {
diff --git a/go/ssa/methods.go b/go/ssa/methods.go
index 03ef625..4797b39 100644
--- a/go/ssa/methods.go
+++ b/go/ssa/methods.go
@@ -261,7 +261,7 @@
 				visit(T.At(i).Type(), false)
 			}
 
-		case *typeparams.TypeParam, *typeparams.Union:
+		case *types.TypeParam, *types.Union:
 			// forEachReachable must not be called on parameterized types.
 			panic(T)
 
diff --git a/go/ssa/parameterized.go b/go/ssa/parameterized.go
index 656417a..63160b4 100644
--- a/go/ssa/parameterized.go
+++ b/go/ssa/parameterized.go
@@ -117,7 +117,7 @@
 		}
 		return w.isParameterizedLocked(t.Underlying()) // recurse for types local to parameterized functions
 
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		return true
 
 	default:
diff --git a/go/ssa/print.go b/go/ssa/print.go
index 7f34a7b..727a735 100644
--- a/go/ssa/print.go
+++ b/go/ssa/print.go
@@ -17,7 +17,6 @@
 	"strings"
 
 	"golang.org/x/tools/go/types/typeutil"
-	"golang.org/x/tools/internal/typeparams"
 )
 
 // relName returns the name of v relative to i.
@@ -51,7 +50,7 @@
 	return s
 }
 
-func relTerm(term *typeparams.Term, from *types.Package) string {
+func relTerm(term *types.Term, from *types.Package) string {
 	s := relType(term.Type(), from)
 	if term.Tilde() {
 		return "~" + s
diff --git a/go/ssa/ssa.go b/go/ssa/ssa.go
index 58a641a..30bf4bc 100644
--- a/go/ssa/ssa.go
+++ b/go/ssa/ssa.go
@@ -27,8 +27,8 @@
 	mode       BuilderMode                 // set of mode bits for SSA construction
 	MethodSets typeutil.MethodSetCache     // cache of type-checker's method-sets
 
-	canon *canonizer          // type canonicalization map
-	ctxt  *typeparams.Context // cache for type checking instantiations
+	canon *canonizer     // type canonicalization map
+	ctxt  *types.Context // cache for type checking instantiations
 
 	methodsMu  sync.Mutex
 	methodSets typeutil.Map // maps type to its concrete *methodSet
@@ -339,10 +339,10 @@
 	referrers []Instruction // referring instructions (iff Parent() != nil)
 	anonIdx   int32         // position of a nested function in parent's AnonFuncs. fn.Parent()!=nil => fn.Parent().AnonFunc[fn.anonIdx] == fn.
 
-	typeparams     *typeparams.TypeParamList // type parameters of this function. typeparams.Len() > 0 => generic or instance of generic function
-	typeargs       []types.Type              // type arguments that instantiated typeparams. len(typeargs) > 0 => instance of generic function
-	topLevelOrigin *Function                 // the origin function if this is an instance of a source function. nil if Parent()!=nil.
-	generic        *generic                  // instances of this function, if generic
+	typeparams     *types.TypeParamList // type parameters of this function. typeparams.Len() > 0 => generic or instance of generic function
+	typeargs       []types.Type         // type arguments that instantiated typeparams. len(typeargs) > 0 => instance of generic function
+	topLevelOrigin *Function            // the origin function if this is an instance of a source function. nil if Parent()!=nil.
+	generic        *generic             // instances of this function, if generic
 
 	// The following fields are cleared after building.
 	currentBlock *BasicBlock              // where to emit code
@@ -690,8 +690,8 @@
 type MultiConvert struct {
 	register
 	X    Value
-	from []*typeparams.Term
-	to   []*typeparams.Term
+	from []*types.Term
+	to   []*types.Term
 }
 
 // ChangeInterface constructs a value of one interface type from a
@@ -1539,10 +1539,7 @@
 
 // TypeParams are the function's type parameters if generic or the
 // type parameters that were instantiated if fn is an instantiation.
-//
-// TODO(taking): declare result type as *types.TypeParamList
-// after we drop support for go1.17.
-func (fn *Function) TypeParams() *typeparams.TypeParamList {
+func (fn *Function) TypeParams() *types.TypeParamList {
 	return fn.typeparams
 }
 
diff --git a/go/ssa/subst.go b/go/ssa/subst.go
index 23d19ae..ae8718d 100644
--- a/go/ssa/subst.go
+++ b/go/ssa/subst.go
@@ -18,11 +18,11 @@
 //
 // Not concurrency-safe.
 type subster struct {
-	replacements map[*typeparams.TypeParam]types.Type // values should contain no type params
-	cache        map[types.Type]types.Type            // cache of subst results
-	ctxt         *typeparams.Context                  // cache for instantiation
-	scope        *types.Scope                         // *types.Named declared within this scope can be substituted (optional)
-	debug        bool                                 // perform extra debugging checks
+	replacements map[*types.TypeParam]types.Type // values should contain no type params
+	cache        map[types.Type]types.Type       // cache of subst results
+	ctxt         *types.Context                  // cache for instantiation
+	scope        *types.Scope                    // *types.Named declared within this scope can be substituted (optional)
+	debug        bool                            // perform extra debugging checks
 	// TODO(taking): consider adding Pos
 	// TODO(zpavlinovic): replacements can contain type params
 	// when generating instances inside of a generic function body.
@@ -31,11 +31,11 @@
 // Returns a subster that replaces tparams[i] with targs[i]. Uses ctxt as a cache.
 // targs should not contain any types in tparams.
 // scope is the (optional) lexical block of the generic function for which we are substituting.
-func makeSubster(ctxt *typeparams.Context, scope *types.Scope, tparams *typeparams.TypeParamList, targs []types.Type, debug bool) *subster {
+func makeSubster(ctxt *types.Context, scope *types.Scope, tparams *types.TypeParamList, targs []types.Type, debug bool) *subster {
 	assert(tparams.Len() == len(targs), "makeSubster argument count must match")
 
 	subst := &subster{
-		replacements: make(map[*typeparams.TypeParam]types.Type, tparams.Len()),
+		replacements: make(map[*types.TypeParam]types.Type, tparams.Len()),
 		cache:        make(map[types.Type]types.Type),
 		ctxt:         ctxt,
 		scope:        scope,
@@ -82,7 +82,7 @@
 
 	// fall through if result r will be identical to t, types.Identical(r, t).
 	switch t := t.(type) {
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		r := subst.replacements[t]
 		assert(r != nil, "type param without replacement encountered")
 		return r
@@ -131,7 +131,7 @@
 	case *types.Signature:
 		return subst.signature(t)
 
-	case *typeparams.Union:
+	case *types.Union:
 		return subst.union(t)
 
 	case *types.Interface:
@@ -220,14 +220,14 @@
 	return v
 }
 
-func (subst *subster) union(u *typeparams.Union) *typeparams.Union {
-	var out []*typeparams.Term // nil => no updates
+func (subst *subster) union(u *types.Union) *types.Union {
+	var out []*types.Term // nil => no updates
 
 	for i, n := 0, u.Len(); i < n; i++ {
 		t := u.Term(i)
 		r := subst.typ(t.Type())
 		if r != t.Type() && out == nil {
-			out = make([]*typeparams.Term, n)
+			out = make([]*types.Term, n)
 			for j := 0; j < i; j++ {
 				out[j] = u.Term(j)
 			}
@@ -422,7 +422,7 @@
 	}()
 
 	switch t := t.(type) {
-	case *typeparams.TypeParam, *types.Basic:
+	case *types.TypeParam, *types.Basic:
 		return false
 	case *types.Array:
 		return reaches(t.Elem(), c)
@@ -451,7 +451,7 @@
 			return true
 		}
 		return reaches(t.Params(), c) || reaches(t.Results(), c)
-	case *typeparams.Union:
+	case *types.Union:
 		for i := 0; i < t.Len(); i++ {
 			if reaches(t.Term(i).Type(), c) {
 				return true
diff --git a/go/ssa/util.go b/go/ssa/util.go
index 63fbbc1..dd6ff19 100644
--- a/go/ssa/util.go
+++ b/go/ssa/util.go
@@ -352,7 +352,7 @@
 }
 
 // instantiateMethod instantiates m with targs and returns a canonical representative for this method.
-func (canon *canonizer) instantiateMethod(m *types.Func, targs []types.Type, ctxt *typeparams.Context) *types.Func {
+func (canon *canonizer) instantiateMethod(m *types.Func, targs []types.Type, ctxt *types.Context) *types.Func {
 	recv := recvType(m)
 	if p, ok := recv.(*types.Pointer); ok {
 		recv = p.Elem()
diff --git a/go/types/objectpath/objectpath.go b/go/types/objectpath/objectpath.go
index e742ecc..86f8983 100644
--- a/go/types/objectpath/objectpath.go
+++ b/go/types/objectpath/objectpath.go
@@ -223,7 +223,7 @@
 	//    Reject obviously non-viable cases.
 	switch obj := obj.(type) {
 	case *types.TypeName:
-		if _, ok := obj.Type().(*typeparams.TypeParam); !ok {
+		if _, ok := obj.Type().(*types.TypeParam); !ok {
 			// With the exception of type parameters, only package-level type names
 			// have a path.
 			return "", fmt.Errorf("no path for %v", obj)
@@ -505,7 +505,7 @@
 			}
 		}
 		return nil
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		name := T.Obj()
 		if name == obj {
 			return append(path, opObj)
@@ -525,7 +525,7 @@
 	panic(T)
 }
 
-func findTypeParam(obj types.Object, list *typeparams.TypeParamList, path []byte, seen map[*types.TypeName]bool) []byte {
+func findTypeParam(obj types.Object, list *types.TypeParamList, path []byte, seen map[*types.TypeName]bool) []byte {
 	for i := 0; i < list.Len(); i++ {
 		tparam := list.At(i)
 		path2 := appendOpArg(path, opTypeParam, i)
@@ -562,7 +562,7 @@
 	}
 	// abstraction of *types.{Named,Signature}
 	type hasTypeParams interface {
-		TypeParams() *typeparams.TypeParamList
+		TypeParams() *types.TypeParamList
 	}
 	// abstraction of *types.{Named,TypeParam}
 	type hasObj interface {
@@ -664,7 +664,7 @@
 			t = tparams.At(index)
 
 		case opConstraint:
-			tparam, ok := t.(*typeparams.TypeParam)
+			tparam, ok := t.(*types.TypeParam)
 			if !ok {
 				return nil, fmt.Errorf("cannot apply %q to %s (got %T, want type parameter)", code, t, t)
 			}
diff --git a/go/types/typeutil/callee.go b/go/types/typeutil/callee.go
index 90b3ab0..90dc541 100644
--- a/go/types/typeutil/callee.go
+++ b/go/types/typeutil/callee.go
@@ -22,7 +22,7 @@
 	// Look through type instantiation if necessary.
 	isInstance := false
 	switch fun.(type) {
-	case *ast.IndexExpr, *typeparams.IndexListExpr:
+	case *ast.IndexExpr, *ast.IndexListExpr:
 		// When extracting the callee from an *IndexExpr, we need to check that
 		// it is a *types.Func and not a *types.Var.
 		// Example: Don't match a slice m within the expression `m[0]()`.
diff --git a/go/types/typeutil/map.go b/go/types/typeutil/map.go
index 7bd2fdb..6b67ca8 100644
--- a/go/types/typeutil/map.go
+++ b/go/types/typeutil/map.go
@@ -219,7 +219,7 @@
 	// generic types or functions, and instantiated signatures do not have type
 	// parameter lists, we should never encounter a second non-empty type
 	// parameter list when hashing a generic signature.
-	sigTParams *typeparams.TypeParamList
+	sigTParams *types.TypeParamList
 }
 
 // MakeHasher returns a new Hasher instance.
@@ -318,7 +318,7 @@
 
 		return hash + 3*h.hashTuple(t.Params()) + 5*h.hashTuple(t.Results())
 
-	case *typeparams.Union:
+	case *types.Union:
 		return h.hashUnion(t)
 
 	case *types.Interface:
@@ -361,7 +361,7 @@
 		}
 		return hash
 
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		return h.hashTypeParam(t)
 
 	case *types.Tuple:
@@ -381,7 +381,7 @@
 	return hash
 }
 
-func (h Hasher) hashUnion(t *typeparams.Union) uint32 {
+func (h Hasher) hashUnion(t *types.Union) uint32 {
 	// Hash type restrictions.
 	terms, err := typeparams.UnionTermSet(t)
 	// if err != nil t has invalid type restrictions. Fall back on a non-zero
@@ -392,7 +392,7 @@
 	return h.hashTermSet(terms)
 }
 
-func (h Hasher) hashTermSet(terms []*typeparams.Term) uint32 {
+func (h Hasher) hashTermSet(terms []*types.Term) uint32 {
 	hash := 9157 + 2*uint32(len(terms))
 	for _, term := range terms {
 		// term order is not significant.
@@ -416,7 +416,7 @@
 // are not identical.
 //
 // Otherwise the hash of t depends only on t's pointer identity.
-func (h Hasher) hashTypeParam(t *typeparams.TypeParam) uint32 {
+func (h Hasher) hashTypeParam(t *types.TypeParam) uint32 {
 	if h.sigTParams != nil {
 		i := t.Index()
 		if i >= 0 && i < h.sigTParams.Len() && t == h.sigTParams.At(i) {
@@ -489,7 +489,7 @@
 	case *types.Pointer:
 		return 4393139
 
-	case *typeparams.Union:
+	case *types.Union:
 		return 562448657
 
 	case *types.Interface:
@@ -504,7 +504,7 @@
 	case *types.Named:
 		return h.hashPtr(t.Obj())
 
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		return h.hashPtr(t.Obj())
 	}
 	panic(fmt.Sprintf("shallowHash: %T: %v", t, t))
diff --git a/go/types/typeutil/map_test.go b/go/types/typeutil/map_test.go
index 4197b69..5d875ce 100644
--- a/go/types/typeutil/map_test.go
+++ b/go/types/typeutil/map_test.go
@@ -277,7 +277,7 @@
 		CI      = C.Underlying().(*types.Interface)
 		I       = scope.Lookup("I").Type()
 		II      = I.Underlying().(*types.Interface)
-		U       = CI.EmbeddedType(0).(*typeparams.Union)
+		U       = CI.EmbeddedType(0).(*types.Union)
 		Fa1     = scope.Lookup("Fa1").Type().(*types.Signature)
 		Fa2     = scope.Lookup("Fa2").Type().(*types.Signature)
 		Fa1P    = typeparams.ForSignature(Fa1).At(0)
diff --git a/godoc/linkify.go b/godoc/linkify.go
index cf266d0..ad773b8 100644
--- a/godoc/linkify.go
+++ b/godoc/linkify.go
@@ -17,8 +17,6 @@
 	"go/token"
 	"io"
 	"strconv"
-
-	"golang.org/x/tools/internal/typeparams"
 )
 
 // LinkifyText HTML-escapes source text and writes it to w.
@@ -116,7 +114,7 @@
 					if ident, _ := x.Index.(*ast.Ident); ident != nil {
 						typeParams[ident.Name] = true
 					}
-				case *typeparams.IndexListExpr:
+				case *ast.IndexListExpr:
 					for _, index := range x.Indices {
 						if ident, _ := index.(*ast.Ident); ident != nil {
 							typeParams[ident.Name] = true
diff --git a/godoc/server.go b/godoc/server.go
index a6df6d7..afb28e2 100644
--- a/godoc/server.go
+++ b/godoc/server.go
@@ -29,7 +29,6 @@
 	"golang.org/x/tools/godoc/analysis"
 	"golang.org/x/tools/godoc/util"
 	"golang.org/x/tools/godoc/vfs"
-	"golang.org/x/tools/internal/typeparams"
 )
 
 // handlerServer is a migration from an old godoc http Handler type.
@@ -471,7 +470,7 @@
 				typeName = x.Name
 			case *ast.IndexExpr:
 				typeName = x.X.(*ast.Ident).Name
-			case *typeparams.IndexListExpr:
+			case *ast.IndexListExpr:
 				typeName = x.X.(*ast.Ident).Name
 			}
 			name = typeName + "_" + name
diff --git a/gopls/internal/analysis/fillstruct/fillstruct.go b/gopls/internal/analysis/fillstruct/fillstruct.go
index 4b1bb4a..b7bb17b 100644
--- a/gopls/internal/analysis/fillstruct/fillstruct.go
+++ b/gopls/internal/analysis/fillstruct/fillstruct.go
@@ -29,7 +29,6 @@
 	"golang.org/x/tools/gopls/internal/util/safetoken"
 	"golang.org/x/tools/internal/analysisinternal"
 	"golang.org/x/tools/internal/fuzzy"
-	"golang.org/x/tools/internal/typeparams"
 )
 
 const Doc = `note incomplete struct initializations
@@ -493,7 +492,7 @@
 		}
 
 	case *types.Interface:
-		if param, ok := typ.(*typeparams.TypeParam); ok {
+		if param, ok := typ.(*types.TypeParam); ok {
 			// *new(T) is the zero value of a type parameter T.
 			// TODO(adonovan): one could give a more specific zero
 			// value if the type has a core type that is, say,
diff --git a/gopls/internal/lsp/cache/methodsets/methodsets.go b/gopls/internal/lsp/cache/methodsets/methodsets.go
index 5199400..ca51409 100644
--- a/gopls/internal/lsp/cache/methodsets/methodsets.go
+++ b/gopls/internal/lsp/cache/methodsets/methodsets.go
@@ -434,7 +434,7 @@
 				buf.WriteString("interface{...}")
 			}
 
-		case *typeparams.TypeParam:
+		case *types.TypeParam:
 			tricky = true
 			// TODO(adonovan): refine this by adding a numeric suffix
 			// indicating the index among the receiver type's parameters.
diff --git a/gopls/internal/lsp/cache/typerefs/refs.go b/gopls/internal/lsp/cache/typerefs/refs.go
index 95c4796..878f53d 100644
--- a/gopls/internal/lsp/cache/typerefs/refs.go
+++ b/gopls/internal/lsp/cache/typerefs/refs.go
@@ -523,7 +523,7 @@
 		visitExpr(n.X, f)
 		visitExpr(n.Index, f) // may affect type for instantiations
 
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		visitExpr(n.X, f)
 		for _, index := range n.Indices {
 			visitExpr(index, f) // may affect the type for instantiations
diff --git a/gopls/internal/lsp/source/completion/completion.go b/gopls/internal/lsp/source/completion/completion.go
index a9f52d4..6b1665f 100644
--- a/gopls/internal/lsp/source/completion/completion.go
+++ b/gopls/internal/lsp/source/completion/completion.go
@@ -2345,7 +2345,7 @@
 				}
 			}
 			return inf
-		case *typeparams.IndexListExpr:
+		case *ast.IndexListExpr:
 			if node.Lbrack < c.pos && c.pos <= node.Rbrack {
 				if tv, ok := c.pkg.GetTypesInfo().Types[node.X]; ok {
 					if ct := expectedConstraint(tv.Type, exprAtPos(c.pos, node.Indices)); ct != nil {
@@ -2438,7 +2438,7 @@
 	// If our expected type is an uninstantiated generic type param,
 	// swap to the constraint which will do a decent job filtering
 	// candidates.
-	if tp, _ := inf.objType.(*typeparams.TypeParam); tp != nil {
+	if tp, _ := inf.objType.(*types.TypeParam); tp != nil {
 		inf.objType = tp.Constraint()
 	}
 
@@ -2446,7 +2446,7 @@
 }
 
 func expectedConstraint(t types.Type, idx int) types.Type {
-	var tp *typeparams.TypeParamList
+	var tp *types.TypeParamList
 	if named, _ := t.(*types.Named); named != nil {
 		tp = typeparams.ForNamed(named)
 	} else if sig, _ := t.Underlying().(*types.Signature); sig != nil {
@@ -2960,7 +2960,7 @@
 		return false
 	}
 
-	if _, ok := from.(*typeparams.TypeParam); ok {
+	if _, ok := from.(*types.TypeParam); ok {
 		return false
 	}
 
diff --git a/gopls/internal/lsp/source/completion/literal.go b/gopls/internal/lsp/source/completion/literal.go
index 440e41a..fe97269 100644
--- a/gopls/internal/lsp/source/completion/literal.go
+++ b/gopls/internal/lsp/source/completion/literal.go
@@ -194,7 +194,7 @@
 			name = p.Name()
 		)
 
-		if tp, _ := p.Type().(*typeparams.TypeParam); tp != nil && !c.typeParamInScope(tp) {
+		if tp, _ := p.Type().(*types.TypeParam); tp != nil && !c.typeParamInScope(tp) {
 			hasTypeParams = true
 		}
 
@@ -285,7 +285,7 @@
 				typeStr = strings.Replace(typeStr, "[]", "...", 1)
 			}
 
-			if tp, _ := p.Type().(*typeparams.TypeParam); tp != nil && !c.typeParamInScope(tp) {
+			if tp, _ := p.Type().(*types.TypeParam); tp != nil && !c.typeParamInScope(tp) {
 				snip.WritePlaceholder(func(snip *snippet.Builder) {
 					snip.WriteText(typeStr)
 				})
@@ -306,7 +306,7 @@
 
 	var resultHasTypeParams bool
 	for i := 0; i < results.Len(); i++ {
-		if tp, _ := results.At(i).Type().(*typeparams.TypeParam); tp != nil && !c.typeParamInScope(tp) {
+		if tp, _ := results.At(i).Type().(*types.TypeParam); tp != nil && !c.typeParamInScope(tp) {
 			resultHasTypeParams = true
 		}
 	}
@@ -339,7 +339,7 @@
 			}
 			return
 		}
-		if tp, _ := r.Type().(*typeparams.TypeParam); tp != nil && !c.typeParamInScope(tp) {
+		if tp, _ := r.Type().(*types.TypeParam); tp != nil && !c.typeParamInScope(tp) {
 			snip.WritePlaceholder(func(snip *snippet.Builder) {
 				snip.WriteText(text)
 			})
@@ -558,7 +558,7 @@
 
 	for i := 0; i < tas.Len(); i++ {
 		switch ta := tas.At(i).(type) {
-		case *typeparams.TypeParam:
+		case *types.TypeParam:
 			// A *TypeParam only counts as specified if it is currently in
 			// scope (i.e. we are in a generic definition).
 			if !c.typeParamInScope(ta) {
@@ -576,7 +576,7 @@
 // typeParamInScope returns whether tp's object is in scope at c.pos.
 // This tells you whether you are in a generic definition and can
 // assume tp has been specified.
-func (c *completer) typeParamInScope(tp *typeparams.TypeParam) bool {
+func (c *completer) typeParamInScope(tp *types.TypeParam) bool {
 	obj := tp.Obj()
 	if obj == nil {
 		return false
diff --git a/gopls/internal/lsp/source/hover.go b/gopls/internal/lsp/source/hover.go
index 7e3efef..9e9f5dd 100644
--- a/gopls/internal/lsp/source/hover.go
+++ b/gopls/internal/lsp/source/hover.go
@@ -224,7 +224,7 @@
 	//
 	// TODO(adonovan): this logic belongs in objectString.
 	_, isTypeName := obj.(*types.TypeName)
-	_, isTypeParam := obj.Type().(*typeparams.TypeParam)
+	_, isTypeParam := obj.Type().(*types.TypeParam)
 	if isTypeName && !isTypeParam {
 		spec, ok := spec.(*ast.TypeSpec)
 		if !ok {
@@ -799,7 +799,7 @@
 // TODO(rfindley): there appears to be zero(!) tests for this functionality.
 func HoverDocForObject(ctx context.Context, snapshot *cache.Snapshot, fset *token.FileSet, obj types.Object) (*ast.CommentGroup, error) {
 	if _, isTypeName := obj.(*types.TypeName); isTypeName {
-		if _, isTypeParam := obj.Type().(*typeparams.TypeParam); isTypeParam {
+		if _, isTypeParam := obj.Type().(*types.TypeParam); isTypeParam {
 			return nil, nil
 		}
 	}
diff --git a/gopls/internal/lsp/source/invertifcondition.go b/gopls/internal/lsp/source/invertifcondition.go
index 8188265..cd19344 100644
--- a/gopls/internal/lsp/source/invertifcondition.go
+++ b/gopls/internal/lsp/source/invertifcondition.go
@@ -14,7 +14,6 @@
 	"golang.org/x/tools/go/analysis"
 	"golang.org/x/tools/go/ast/astutil"
 	"golang.org/x/tools/gopls/internal/util/safetoken"
-	"golang.org/x/tools/internal/typeparams"
 )
 
 // invertIfCondition is a singleFileFixFunc that inverts an if/else statement
@@ -131,7 +130,7 @@
 	oldText := string(src[condStart.Offset:condEnd.Offset])
 
 	switch expr := cond.(type) {
-	case *ast.Ident, *ast.ParenExpr, *ast.CallExpr, *ast.StarExpr, *ast.IndexExpr, *typeparams.IndexListExpr, *ast.SelectorExpr:
+	case *ast.Ident, *ast.ParenExpr, *ast.CallExpr, *ast.StarExpr, *ast.IndexExpr, *ast.IndexListExpr, *ast.SelectorExpr:
 		newText := "!" + oldText
 		if oldText == "true" {
 			newText = "false"
diff --git a/gopls/internal/lsp/source/rename.go b/gopls/internal/lsp/source/rename.go
index c87302d..adc3ce9 100644
--- a/gopls/internal/lsp/source/rename.go
+++ b/gopls/internal/lsp/source/rename.go
@@ -353,7 +353,7 @@
 		// of the type parameters, unlike methods).
 		switch obj.(type) { // avoid "obj :=" since cases reassign the var
 		case *types.TypeName:
-			if _, ok := obj.Type().(*typeparams.TypeParam); ok {
+			if _, ok := obj.Type().(*types.TypeParam); ok {
 				// As with capitalized function parameters below, type parameters are
 				// local.
 				goto skipObjectPath
diff --git a/gopls/internal/lsp/source/types_format.go b/gopls/internal/lsp/source/types_format.go
index 4cc699b..ecb33c6 100644
--- a/gopls/internal/lsp/source/types_format.go
+++ b/gopls/internal/lsp/source/types_format.go
@@ -182,7 +182,7 @@
 // FormatTypeParams turns TypeParamList into its Go representation, such as:
 // [T, Y]. Note that it does not print constraints as this is mainly used for
 // formatting type params in method receivers.
-func FormatTypeParams(tparams *typeparams.TypeParamList) string {
+func FormatTypeParams(tparams *types.TypeParamList) string {
 	if tparams == nil || tparams.Len() == 0 {
 		return ""
 	}
@@ -430,12 +430,12 @@
 			Rbrack: expr.Rbrack,
 		}
 
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		indices := make([]ast.Expr, len(expr.Indices))
 		for i, idx := range expr.Indices {
 			indices[i] = qualifyTypeExpr(idx, qf)
 		}
-		return &typeparams.IndexListExpr{
+		return &ast.IndexListExpr{
 			X:       qualifyTypeExpr(expr.X, qf),
 			Lbrack:  expr.Lbrack,
 			Indices: indices,
diff --git a/gopls/internal/lsp/source/util.go b/gopls/internal/lsp/source/util.go
index 5745994..1d58896 100644
--- a/gopls/internal/lsp/source/util.go
+++ b/gopls/internal/lsp/source/util.go
@@ -22,7 +22,6 @@
 	"golang.org/x/tools/gopls/internal/util/safetoken"
 	"golang.org/x/tools/gopls/internal/util/typesutil"
 	"golang.org/x/tools/internal/tokeninternal"
-	"golang.org/x/tools/internal/typeparams"
 )
 
 // IsGenerated gets and reads the file denoted by uri and reports
@@ -423,7 +422,7 @@
 	switch ix := x.(type) { // check for instantiated receivers
 	case *ast.IndexExpr:
 		x = ix.X
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		x = ix.X
 	}
 	switch x := x.(type) {
diff --git a/gopls/internal/server/semantic.go b/gopls/internal/server/semantic.go
index 0877690..1421e9b 100644
--- a/gopls/internal/server/semantic.go
+++ b/gopls/internal/server/semantic.go
@@ -373,7 +373,7 @@
 	case *ast.IncDecStmt:
 		e.token(x.TokPos, len(x.Tok.String()), tokOperator, nil)
 	case *ast.IndexExpr:
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 	case *ast.InterfaceType:
 		e.token(x.Interface, len("interface"), tokKeyword, nil)
 	case *ast.KeyValueExpr:
@@ -509,7 +509,7 @@
 		var mods []string
 		if _, ok := y.Type().(*types.Basic); ok {
 			mods = []string{"defaultLibrary"}
-		} else if _, ok := y.Type().(*typeparams.TypeParam); ok {
+		} else if _, ok := y.Type().(*types.TypeParam); ok {
 			tok(x.Pos(), len(x.String()), tokTypeParam, mods)
 			break
 		}
@@ -593,9 +593,8 @@
 		*ast.ReturnStmt, *ast.ChanType, *ast.SendStmt,
 		*ast.ForStmt,      // possibly incomplete
 		*ast.IfStmt,       /* condition */
-		*ast.KeyValueExpr: // either key or value
-		return tokVariable, nil
-	case *typeparams.IndexListExpr:
+		*ast.KeyValueExpr, // either key or value
+		*ast.IndexListExpr:
 		return tokVariable, nil
 	case *ast.Ellipsis:
 		return tokType, nil
diff --git a/gopls/internal/util/astutil/util.go b/gopls/internal/util/astutil/util.go
index d975c5a..4fc3135 100644
--- a/gopls/internal/util/astutil/util.go
+++ b/gopls/internal/util/astutil/util.go
@@ -35,7 +35,7 @@
 
 	// unpack type parameters, if any
 	switch rtyp.(type) {
-	case *ast.IndexExpr, *typeparams.IndexListExpr:
+	case *ast.IndexExpr, *ast.IndexListExpr:
 		var indices []ast.Expr
 		rtyp, _, indices, _ = typeparams.UnpackIndexExpr(rtyp)
 		for _, arg := range indices {
diff --git a/internal/facts/imports.go b/internal/facts/imports.go
index f64695e..5c69b75 100644
--- a/internal/facts/imports.go
+++ b/internal/facts/imports.go
@@ -108,11 +108,11 @@
 			for i := 0; i < T.NumEmbeddeds(); i++ {
 				addType(T.EmbeddedType(i)) // walk Embedded for implicits
 			}
-		case *typeparams.Union:
+		case *types.Union:
 			for i := 0; i < T.Len(); i++ {
 				addType(T.Term(i).Type())
 			}
-		case *typeparams.TypeParam:
+		case *types.TypeParam:
 			if !typs[T] {
 				typs[T] = true
 				addObj(T.Obj())
diff --git a/internal/gcimporter/bexport_test.go b/internal/gcimporter/bexport_test.go
index 978c46e..f722d00 100644
--- a/internal/gcimporter/bexport_test.go
+++ b/internal/gcimporter/bexport_test.go
@@ -184,8 +184,8 @@
 				return fmt.Errorf("tuple element %d: %s", i, err)
 			}
 		}
-	case *typeparams.TypeParam:
-		y := y.(*typeparams.TypeParam)
+	case *types.TypeParam:
+		y := y.(*types.TypeParam)
 		if x.String() != y.String() {
 			return fmt.Errorf("unequal named types: %s vs %s", x, y)
 		}
@@ -266,7 +266,7 @@
 	return typ
 }
 
-func equalTypeArgs(x, y *typeparams.TypeList) error {
+func equalTypeArgs(x, y *types.TypeList) error {
 	if x.Len() != y.Len() {
 		return fmt.Errorf("unequal lengths: %d vs %d", x.Len(), y.Len())
 	}
@@ -278,7 +278,7 @@
 	return nil
 }
 
-func equalTypeParams(x, y *typeparams.TypeParamList) error {
+func equalTypeParams(x, y *types.TypeParamList) error {
 	if x.Len() != y.Len() {
 		return fmt.Errorf("unequal lengths: %d vs %d", x.Len(), y.Len())
 	}
diff --git a/internal/gcimporter/iexport.go b/internal/gcimporter/iexport.go
index 6103dd7..828f555 100644
--- a/internal/gcimporter/iexport.go
+++ b/internal/gcimporter/iexport.go
@@ -507,7 +507,7 @@
 	case *types.TypeName:
 		t := obj.Type()
 
-		if tparam, ok := t.(*typeparams.TypeParam); ok {
+		if tparam, ok := t.(*types.TypeParam); ok {
 			w.tag('P')
 			w.pos(obj.Pos())
 			constraint := tparam.Constraint()
@@ -752,7 +752,7 @@
 		w.startType(definedType)
 		w.qualifiedType(t.Obj())
 
-	case *typeparams.TypeParam:
+	case *types.TypeParam:
 		w.startType(typeParamType)
 		w.qualifiedType(t.Obj())
 
@@ -868,7 +868,7 @@
 			w.signature(sig)
 		}
 
-	case *typeparams.Union:
+	case *types.Union:
 		w.startType(unionType)
 		nt := t.Len()
 		w.uint64(uint64(nt))
@@ -948,14 +948,14 @@
 	}
 }
 
-func (w *exportWriter) typeList(ts *typeparams.TypeList, pkg *types.Package) {
+func (w *exportWriter) typeList(ts *types.TypeList, pkg *types.Package) {
 	w.uint64(uint64(ts.Len()))
 	for i := 0; i < ts.Len(); i++ {
 		w.typ(ts.At(i), pkg)
 	}
 }
 
-func (w *exportWriter) tparamList(prefix string, list *typeparams.TypeParamList, pkg *types.Package) {
+func (w *exportWriter) tparamList(prefix string, list *types.TypeParamList, pkg *types.Package) {
 	ll := uint64(list.Len())
 	w.uint64(ll)
 	for i := 0; i < list.Len(); i++ {
@@ -973,7 +973,7 @@
 // differs from its actual object name: it is prefixed with a qualifier, and
 // blank type parameter names are disambiguated by their index in the type
 // parameter list.
-func tparamExportName(prefix string, tparam *typeparams.TypeParam) string {
+func tparamExportName(prefix string, tparam *types.TypeParam) string {
 	assert(prefix != "")
 	name := tparam.Obj().Name()
 	if name == "_" {
diff --git a/internal/gcimporter/iimport.go b/internal/gcimporter/iimport.go
index 8e64cf6..391764f 100644
--- a/internal/gcimporter/iimport.go
+++ b/internal/gcimporter/iimport.go
@@ -339,7 +339,7 @@
 }
 
 type setConstraintArgs struct {
-	t          *typeparams.TypeParam
+	t          *types.TypeParam
 	constraint types.Type
 }
 
@@ -549,7 +549,7 @@
 		r.declare(types.NewConst(pos, r.currPkg, name, typ, val))
 
 	case 'F', 'G':
-		var tparams []*typeparams.TypeParam
+		var tparams []*types.TypeParam
 		if tag == 'G' {
 			tparams = r.tparamList()
 		}
@@ -584,11 +584,11 @@
 				base := baseType(recv.Type())
 				assert(base != nil)
 				targs := typeparams.NamedTypeArgs(base)
-				var rparams []*typeparams.TypeParam
+				var rparams []*types.TypeParam
 				if targs.Len() > 0 {
-					rparams = make([]*typeparams.TypeParam, targs.Len())
+					rparams = make([]*types.TypeParam, targs.Len())
 					for i := range rparams {
-						rparams[i] = targs.At(i).(*typeparams.TypeParam)
+						rparams[i] = targs.At(i).(*types.TypeParam)
 					}
 				}
 				msig := r.signature(recv, rparams, nil)
@@ -976,7 +976,7 @@
 		if r.p.version < iexportVersionGenerics {
 			errorf("unexpected instantiation type")
 		}
-		terms := make([]*typeparams.Term, r.uint64())
+		terms := make([]*types.Term, r.uint64())
 		for i := range terms {
 			terms[i] = typeparams.NewTerm(r.bool(), r.typ())
 		}
@@ -1008,23 +1008,23 @@
 	return obj
 }
 
-func (r *importReader) signature(recv *types.Var, rparams []*typeparams.TypeParam, tparams []*typeparams.TypeParam) *types.Signature {
+func (r *importReader) signature(recv *types.Var, rparams []*types.TypeParam, tparams []*types.TypeParam) *types.Signature {
 	params := r.paramList()
 	results := r.paramList()
 	variadic := params.Len() > 0 && r.bool()
 	return typeparams.NewSignatureType(recv, rparams, tparams, params, results, variadic)
 }
 
-func (r *importReader) tparamList() []*typeparams.TypeParam {
+func (r *importReader) tparamList() []*types.TypeParam {
 	n := r.uint64()
 	if n == 0 {
 		return nil
 	}
-	xs := make([]*typeparams.TypeParam, n)
+	xs := make([]*types.TypeParam, n)
 	for i := range xs {
 		// Note: the standard library importer is tolerant of nil types here,
 		// though would panic in SetTypeParams.
-		xs[i] = r.typ().(*typeparams.TypeParam)
+		xs[i] = r.typ().(*types.TypeParam)
 	}
 	return xs
 }
diff --git a/internal/typeparams/common.go b/internal/typeparams/common.go
index d0d0649..ae7e5c5 100644
--- a/internal/typeparams/common.go
+++ b/internal/typeparams/common.go
@@ -42,7 +42,7 @@
 	switch e := n.(type) {
 	case *ast.IndexExpr:
 		return e.X, e.Lbrack, []ast.Expr{e.Index}, e.Rbrack
-	case *IndexListExpr:
+	case *ast.IndexListExpr:
 		return e.X, e.Lbrack, e.Indices, e.Rbrack
 	}
 	return nil, token.NoPos, nil, token.NoPos
@@ -63,7 +63,7 @@
 			Rbrack: rbrack,
 		}
 	default:
-		return &IndexListExpr{
+		return &ast.IndexListExpr{
 			X:       x,
 			Lbrack:  lbrack,
 			Indices: indices,
@@ -74,7 +74,7 @@
 
 // IsTypeParam reports whether t is a type parameter.
 func IsTypeParam(t types.Type) bool {
-	_, ok := t.(*TypeParam)
+	_, ok := t.(*types.TypeParam)
 	return ok
 }
 
@@ -157,7 +157,7 @@
 //
 // In this case, GenericAssignableTo reports that instantiations of Container
 // are assignable to the corresponding instantiation of Interface.
-func GenericAssignableTo(ctxt *Context, V, T types.Type) bool {
+func GenericAssignableTo(ctxt *types.Context, V, T types.Type) bool {
 	// If V and T are not both named, or do not have matching non-empty type
 	// parameter lists, fall back on types.AssignableTo.
 
diff --git a/internal/typeparams/common_test.go b/internal/typeparams/common_test.go
index d1f13fa..b6f355c 100644
--- a/internal/typeparams/common_test.go
+++ b/internal/typeparams/common_test.go
@@ -19,7 +19,7 @@
 	x := &ast.Ident{}
 	i := &ast.Ident{}
 
-	want := &IndexListExpr{X: x, Lbrack: 1, Indices: []ast.Expr{i}, Rbrack: 2}
+	want := &ast.IndexListExpr{X: x, Lbrack: 1, Indices: []ast.Expr{i}, Rbrack: 2}
 	tests := map[ast.Node]bool{
 		&ast.IndexExpr{X: x, Lbrack: 1, Index: i, Rbrack: 2}: true,
 		want:         true,
diff --git a/internal/typeparams/coretype.go b/internal/typeparams/coretype.go
index 7124820..c2dc8e2 100644
--- a/internal/typeparams/coretype.go
+++ b/internal/typeparams/coretype.go
@@ -108,15 +108,15 @@
 //
 // _NormalTerms makes no guarantees about the order of terms, except that it
 // is deterministic.
-func _NormalTerms(typ types.Type) ([]*Term, error) {
+func _NormalTerms(typ types.Type) ([]*types.Term, error) {
 	switch typ := typ.(type) {
-	case *TypeParam:
+	case *types.TypeParam:
 		return StructuralTerms(typ)
-	case *Union:
+	case *types.Union:
 		return UnionTermSet(typ)
 	case *types.Interface:
 		return InterfaceTermSet(typ)
 	default:
-		return []*Term{NewTerm(false, typ)}, nil
+		return []*types.Term{NewTerm(false, typ)}, nil
 	}
 }
diff --git a/internal/typeparams/normalize.go b/internal/typeparams/normalize.go
index 9c631b6..d88efa5 100644
--- a/internal/typeparams/normalize.go
+++ b/internal/typeparams/normalize.go
@@ -60,7 +60,7 @@
 //
 // StructuralTerms makes no guarantees about the order of terms, except that it
 // is deterministic.
-func StructuralTerms(tparam *TypeParam) ([]*Term, error) {
+func StructuralTerms(tparam *types.TypeParam) ([]*types.Term, error) {
 	constraint := tparam.Constraint()
 	if constraint == nil {
 		return nil, fmt.Errorf("%s has nil constraint", tparam)
@@ -78,7 +78,7 @@
 //
 // See the documentation of StructuralTerms for more information on
 // normalization.
-func InterfaceTermSet(iface *types.Interface) ([]*Term, error) {
+func InterfaceTermSet(iface *types.Interface) ([]*types.Term, error) {
 	return computeTermSet(iface)
 }
 
@@ -88,11 +88,11 @@
 //
 // See the documentation of StructuralTerms for more information on
 // normalization.
-func UnionTermSet(union *Union) ([]*Term, error) {
+func UnionTermSet(union *types.Union) ([]*types.Term, error) {
 	return computeTermSet(union)
 }
 
-func computeTermSet(typ types.Type) ([]*Term, error) {
+func computeTermSet(typ types.Type) ([]*types.Term, error) {
 	tset, err := computeTermSetInternal(typ, make(map[types.Type]*termSet), 0)
 	if err != nil {
 		return nil, err
@@ -103,7 +103,7 @@
 	if tset.terms.isAll() {
 		return nil, nil
 	}
-	var terms []*Term
+	var terms []*types.Term
 	for _, term := range tset.terms {
 		terms = append(terms, NewTerm(term.tilde, term.typ))
 	}
@@ -162,7 +162,7 @@
 		tset.terms = allTermlist
 		for i := 0; i < u.NumEmbeddeds(); i++ {
 			embedded := u.EmbeddedType(i)
-			if _, ok := embedded.Underlying().(*TypeParam); ok {
+			if _, ok := embedded.Underlying().(*types.TypeParam); ok {
 				return nil, fmt.Errorf("invalid embedded type %T", embedded)
 			}
 			tset2, err := computeTermSetInternal(embedded, seen, depth+1)
@@ -171,7 +171,7 @@
 			}
 			tset.terms = tset.terms.intersect(tset2.terms)
 		}
-	case *Union:
+	case *types.Union:
 		// The term set of a union is the union of term sets of its terms.
 		tset.terms = nil
 		for i := 0; i < u.Len(); i++ {
@@ -184,7 +184,7 @@
 					return nil, err
 				}
 				terms = tset2.terms
-			case *TypeParam, *Union:
+			case *types.TypeParam, *types.Union:
 				// A stand-alone type parameter or union is not permitted as union
 				// term.
 				return nil, fmt.Errorf("invalid union term %T", t)
@@ -199,7 +199,7 @@
 				return nil, fmt.Errorf("exceeded max term count %d", maxTermCount)
 			}
 		}
-	case *TypeParam:
+	case *types.TypeParam:
 		panic("unreachable")
 	default:
 		// For all other types, the term set is just a single non-tilde term
diff --git a/internal/typeparams/typeparams_go118.go b/internal/typeparams/typeparams_go118.go
index 0bda83d..54e8e97 100644
--- a/internal/typeparams/typeparams_go118.go
+++ b/internal/typeparams/typeparams_go118.go
@@ -9,10 +9,7 @@
 	"go/types"
 )
 
-// TODO(adonovan): melt the aliases away.
-
-// IndexListExpr is an alias for ast.IndexListExpr.
-type IndexListExpr = ast.IndexListExpr
+// TODO(adonovan): melt the trivial functions away.
 
 // ForTypeSpec returns n.TypeParams.
 func ForTypeSpec(n *ast.TypeSpec) *ast.FieldList {
@@ -30,37 +27,28 @@
 	return n.TypeParams
 }
 
-// TypeParam is an alias for types.TypeParam
-type TypeParam = types.TypeParam
-
-// TypeParamList is an alias for types.TypeParamList
-type TypeParamList = types.TypeParamList
-
-// TypeList is an alias for types.TypeList
-type TypeList = types.TypeList
-
 // NewTypeParam calls types.NewTypeParam.
-func NewTypeParam(name *types.TypeName, constraint types.Type) *TypeParam {
+func NewTypeParam(name *types.TypeName, constraint types.Type) *types.TypeParam {
 	return types.NewTypeParam(name, constraint)
 }
 
 // SetTypeParamConstraint calls tparam.SetConstraint(constraint).
-func SetTypeParamConstraint(tparam *TypeParam, constraint types.Type) {
+func SetTypeParamConstraint(tparam *types.TypeParam, constraint types.Type) {
 	tparam.SetConstraint(constraint)
 }
 
 // NewSignatureType calls types.NewSignatureType.
-func NewSignatureType(recv *types.Var, recvTypeParams, typeParams []*TypeParam, params, results *types.Tuple, variadic bool) *types.Signature {
+func NewSignatureType(recv *types.Var, recvTypeParams, typeParams []*types.TypeParam, params, results *types.Tuple, variadic bool) *types.Signature {
 	return types.NewSignatureType(recv, recvTypeParams, typeParams, params, results, variadic)
 }
 
 // ForSignature returns sig.TypeParams()
-func ForSignature(sig *types.Signature) *TypeParamList {
+func ForSignature(sig *types.Signature) *types.TypeParamList {
 	return sig.TypeParams()
 }
 
 // RecvTypeParams returns sig.RecvTypeParams().
-func RecvTypeParams(sig *types.Signature) *TypeParamList {
+func RecvTypeParams(sig *types.Signature) *types.TypeParamList {
 	return sig.RecvTypeParams()
 }
 
@@ -86,18 +74,18 @@
 
 // ForNamed extracts the (possibly empty) type parameter object list from
 // named.
-func ForNamed(named *types.Named) *TypeParamList {
+func ForNamed(named *types.Named) *types.TypeParamList {
 	return named.TypeParams()
 }
 
 // SetForNamed sets the type params tparams on n. Each tparam must be of
 // dynamic type *types.TypeParam.
-func SetForNamed(n *types.Named, tparams []*TypeParam) {
+func SetForNamed(n *types.Named, tparams []*types.TypeParam) {
 	n.SetTypeParams(tparams)
 }
 
 // NamedTypeArgs returns named.TypeArgs().
-func NamedTypeArgs(named *types.Named) *TypeList {
+func NamedTypeArgs(named *types.Named) *types.TypeList {
 	return named.TypeArgs()
 }
 
@@ -106,19 +94,13 @@
 	return named.Origin()
 }
 
-// Term is an alias for types.Term.
-type Term = types.Term
-
 // NewTerm calls types.NewTerm.
-func NewTerm(tilde bool, typ types.Type) *Term {
+func NewTerm(tilde bool, typ types.Type) *types.Term {
 	return types.NewTerm(tilde, typ)
 }
 
-// Union is an alias for types.Union
-type Union = types.Union
-
 // NewUnion calls types.NewUnion.
-func NewUnion(terms []*Term) *Union {
+func NewUnion(terms []*types.Term) *types.Union {
 	return types.NewUnion(terms)
 }
 
@@ -128,23 +110,17 @@
 	info.Instances = make(map[*ast.Ident]types.Instance)
 }
 
-// Instance is an alias for types.Instance.
-type Instance = types.Instance
-
 // GetInstances returns info.Instances.
-func GetInstances(info *types.Info) map[*ast.Ident]Instance {
+func GetInstances(info *types.Info) map[*ast.Ident]types.Instance {
 	return info.Instances
 }
 
-// Context is an alias for types.Context.
-type Context = types.Context
-
 // NewContext calls types.NewContext.
-func NewContext() *Context {
+func NewContext() *types.Context {
 	return types.NewContext()
 }
 
 // Instantiate calls types.Instantiate.
-func Instantiate(ctxt *Context, typ types.Type, targs []types.Type, validate bool) (types.Type, error) {
+func Instantiate(ctxt *types.Context, typ types.Type, targs []types.Type, validate bool) (types.Type, error) {
 	return types.Instantiate(ctxt, typ, targs, validate)
 }
diff --git a/refactor/satisfy/find.go b/refactor/satisfy/find.go
index 9e60af3..19cf472 100644
--- a/refactor/satisfy/find.go
+++ b/refactor/satisfy/find.go
@@ -411,7 +411,7 @@
 			}
 		}
 
-	case *typeparams.IndexListExpr:
+	case *ast.IndexListExpr:
 		// f[X, Y] -- generic instantiation
 
 	case *ast.SliceExpr: