Update go version

This commit is contained in:
dwrz
2026-08-21 10:23:37 +00:00
parent 78248a6145
commit c2e2d9ea02
466 changed files with 67766 additions and 2881 deletions

View File

@@ -5,6 +5,7 @@
package ssa
import (
"fmt"
"go/types"
"golang.org/x/tools/go/types/typeutil"
@@ -56,18 +57,25 @@ type subster struct {
// TODO(taking): consider adding Pos
}
// Returns a subster that replaces tparams[i] with targs[i]. Uses ctxt as a cache.
// targs should not contain any types in tparams.
// Returns a subster that replaces rtparams[i] with rtargs[i] and tparams[i] with targs[i].
// Uses ctxt as a cache. rtargs and targs should not contain any types in rtparams or tparams.
// fn is the generic function for which we are substituting.
func makeSubster(ctxt *types.Context, fn *types.Func, tparams *types.TypeParamList, targs []types.Type) *subster {
assert(tparams.Len() == len(targs), "makeSubster argument count must match")
func makeSubster(ctxt *types.Context, fn *types.Func, rtparams *types.TypeParamList, rtargs []types.Type, tparams *types.TypeParamList, targs []types.Type) *subster {
got := len(rtargs) + len(targs)
want := rtparams.Len() + tparams.Len()
if got != want {
panic(fmt.Sprintf("makeSubster argument count must match: got %d; want %d", got, want))
}
subst := &subster{
replacements: make(map[*types.TypeParam]types.Type, tparams.Len()),
replacements: make(map[*types.TypeParam]types.Type, want),
cache: make(map[types.Type]types.Type),
origin: fn.Origin(),
ctxt: ctxt,
}
for i := 0; i < rtparams.Len(); i++ {
subst.replacements[rtparams.At(i)] = rtargs[i]
}
for i := 0; i < tparams.Len(); i++ {
subst.replacements[tparams.At(i)] = targs[i]
}
@@ -319,10 +327,10 @@ func (subst *subster) interface_(iface *types.Interface) *types.Interface {
func (subst *subster) alias(t *types.Alias) types.Type {
// See subster.named. This follows the same strategy.
tparams := aliases.TypeParams(t)
targs := aliases.TypeArgs(t)
tparams := t.TypeParams()
targs := t.TypeArgs()
tname := t.Obj()
torigin := aliases.Origin(t)
torigin := t.Origin()
if !declaredWithin(tname, subst.origin) {
// t is declared outside of the function origin. So t is a package level type alias.
@@ -361,15 +369,10 @@ func (subst *subster) alias(t *types.Alias) types.Type {
}
// Substitute rhs.
rhs := subst.typ(aliases.Rhs(t))
rhs := subst.typ(t.Rhs())
// Create the fresh alias.
//
// Until 1.27, the result of aliases.NewAlias(...).Type() cannot guarantee it is a *types.Alias.
// However, as t is an *alias.Alias and t is well-typed, then aliases must have been enabled.
// Follow this decision, and always enable aliases here.
const enabled = true
obj := aliases.NewAlias(enabled, tname.Pos(), tname.Pkg(), tname.Name(), rhs, newTParams)
obj := aliases.New(tname.Pos(), tname.Pkg(), tname.Name(), rhs, newTParams)
// Substitute into all of the constraints after they are created.
for i, ntp := range newTParams {