Proposals Unofficial Go proposal tracker

Add NewTypeParamList and NewTypeList constructors

#79603 · go/types · low impact · Implemented in Go 1.28 ·

Code that works with generic methods sometimes needs to treat the receiver's and the method's type parameters as one list. go/types has no exported way to build a *TypeParamList or *TypeList. Tools like the compiler's noder copy lists into slices. x/tools/go/ssa even uses an unsafe cast that depends on the internal layout of TypeParamList.

The proposal adds two constructors to go/types. NewTypeParamList builds a *TypeParamList from type parameters, and NewTypeList builds a *TypeList from types.

func concat(recv, meth *types.TypeParamList) *types.TypeParamList {
    var all []*types.TypeParam
    for tp := range recv.TypeParams() {
        all = append(all, tp)
    }
    for tp := range meth.TypeParams() {
        all = append(all, tp)
    }
    return types.NewTypeParamList(all...)
}

args := types.NewTypeList(types.Typ[types.Int], types.Typ[types.String])
Proposal
#79603 by mrkfrmn
Status
Implemented on Oct 22, 2026
Release
Go 1.28
Impact
low
Area
go/types