vendor: golang.org/x/tools v0.46.0
full diff: https://github.com/golang/tools/compare/v0.45.0...v0.46.0 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
+14
@@ -815,6 +815,12 @@ func (ld *loader) refine(response *DriverResponse) ([]*Package, error) {
|
||||
needsrc: needsrc,
|
||||
goVersion: response.GoVersion,
|
||||
}
|
||||
// Don't trust the driver to respond with duplicate-free
|
||||
// package names (go.dev/issue/63822).
|
||||
if _, ok := ld.pkgs[lpkg.ID]; ok {
|
||||
return nil, fmt.Errorf("%s response contained duplicate packages for ID %q",
|
||||
cond(ld.externalDriver, "go/packages driver", "go list"), lpkg.ID)
|
||||
}
|
||||
ld.pkgs[lpkg.ID] = lpkg
|
||||
if rootIndex >= 0 {
|
||||
initial[rootIndex] = lpkg
|
||||
@@ -1589,3 +1595,11 @@ func usesExportData(cfg *Config) bool {
|
||||
}
|
||||
|
||||
type unit struct{}
|
||||
|
||||
func cond[T any](cond bool, t, f T) T {
|
||||
if cond {
|
||||
return t
|
||||
} else {
|
||||
return f
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -823,6 +823,9 @@ func (p *iexporter) doDecl(obj types.Object) {
|
||||
w.pos(m.Pos())
|
||||
w.string(m.Name())
|
||||
sig, _ := m.Type().(*types.Signature)
|
||||
if w.p.version >= iexportVersionGenericMethods && w.bool(sig.TypeParams().Len() > 0) {
|
||||
w.tparamList(obj.Name()+"."+m.Name(), sig.TypeParams(), obj.Pkg())
|
||||
}
|
||||
|
||||
// Receiver type parameters are type arguments of the receiver type, so
|
||||
// their name must be qualified before exporting recv.
|
||||
|
||||
+14
-10
@@ -48,13 +48,14 @@ func (r *intReader) uint64() uint64 {
|
||||
|
||||
// Keep this in sync with constants in iexport.go.
|
||||
const (
|
||||
iexportVersionGo1_11 = 0
|
||||
iexportVersionPosCol = 1
|
||||
iexportVersionGo1_18 = 2
|
||||
iexportVersionGenerics = 2
|
||||
iexportVersion = iexportVersionGenerics
|
||||
iexportVersionGo1_11 = 0
|
||||
iexportVersionPosCol = 1
|
||||
iexportVersionGo1_18 = 2
|
||||
iexportVersionGenerics = 2
|
||||
iexportVersionGenericMethods = 3
|
||||
iexportVersion = iexportVersionGenericMethods
|
||||
|
||||
iexportVersionCurrent = 2
|
||||
iexportVersionCurrent = 3
|
||||
)
|
||||
|
||||
type ident struct {
|
||||
@@ -179,9 +180,9 @@ func iimportCommon(fset *token.FileSet, getPackages GetPackagesFunc, data []byte
|
||||
|
||||
version = int64(r.uint64())
|
||||
switch version {
|
||||
case iexportVersionGo1_18, iexportVersionPosCol, iexportVersionGo1_11:
|
||||
case iexportVersionGenericMethods, iexportVersionGo1_18, iexportVersionPosCol, iexportVersionGo1_11:
|
||||
default:
|
||||
if version > iexportVersionGo1_18 {
|
||||
if version > iexportVersionGenericMethods {
|
||||
errorf("unstable iexport format version %d, just rebuild compiler and std library", version)
|
||||
} else {
|
||||
errorf("unknown iexport format version %d", version)
|
||||
@@ -614,6 +615,10 @@ func (r *importReader) obj(pkg *types.Package, name string) {
|
||||
for n := r.uint64(); n > 0; n-- {
|
||||
mpos := r.pos()
|
||||
mname := r.ident()
|
||||
var tpars []*types.TypeParam
|
||||
if r.p.version >= iexportVersionGenericMethods && r.bool() {
|
||||
tpars = r.tparamList()
|
||||
}
|
||||
recv := r.param(pkg)
|
||||
|
||||
// If the receiver has any targs, set those as the
|
||||
@@ -628,8 +633,7 @@ func (r *importReader) obj(pkg *types.Package, name string) {
|
||||
rparams[i] = types.Unalias(targs.At(i)).(*types.TypeParam)
|
||||
}
|
||||
}
|
||||
msig := r.signature(pkg, recv, rparams, nil)
|
||||
|
||||
msig := r.signature(pkg, recv, rparams, tpars)
|
||||
named.AddMethod(types.NewFunc(mpos, pkg, mname, msig))
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -37,6 +37,10 @@ func ForEachElement(rtypes *typeutil.Map, msets *typeutil.MethodSetCache, T type
|
||||
tmset := msets.MethodSet(T)
|
||||
for method := range tmset.Methods() {
|
||||
sig := method.Type().(*types.Signature)
|
||||
if sig.TypeParams() != nil {
|
||||
continue // skip type-parameterized methods
|
||||
}
|
||||
|
||||
// It is tempting to call visit(sig, false)
|
||||
// but, as noted in golang.org/cl/65450043,
|
||||
// the Signature.Recv field is ignored by
|
||||
@@ -123,10 +127,10 @@ func ForEachElement(rtypes *typeutil.Map, msets *typeutil.MethodSetCache, T type
|
||||
|
||||
case *types.TypeParam, *types.Union:
|
||||
// forEachReachable must not be called on parameterized types.
|
||||
panic(T)
|
||||
panic(fmt.Sprintf("ForEachElement called on type containing %T", T))
|
||||
|
||||
default:
|
||||
panic(T)
|
||||
panic(fmt.Sprintf("ForEachElement called on unexpected type %T", T))
|
||||
}
|
||||
}
|
||||
visit(T, false)
|
||||
|
||||
+28
@@ -22,6 +22,7 @@ import (
|
||||
"go/ast"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"iter"
|
||||
"reflect"
|
||||
|
||||
"golang.org/x/tools/go/ast/inspector"
|
||||
@@ -242,3 +243,30 @@ func ObjectKind(obj types.Object) string {
|
||||
}
|
||||
return "unknown symbol"
|
||||
}
|
||||
|
||||
// ImplicitFieldSelections returns the sequence of implicit embedded fields
|
||||
// traversed by the given selection. It skips the final leaf field or method.
|
||||
// The boolean component indicates whether the traversal traversed a pointer.
|
||||
func ImplicitFieldSelections(seln types.Selection) iter.Seq2[*types.Var, bool] {
|
||||
return func(yield func(*types.Var, bool) bool) {
|
||||
var (
|
||||
t = seln.Recv()
|
||||
indices = seln.Index()
|
||||
)
|
||||
for _, idx := range indices[:len(indices)-1] {
|
||||
ptr, isPtr := t.Underlying().(*types.Pointer)
|
||||
if isPtr {
|
||||
t = ptr.Elem()
|
||||
}
|
||||
structType, ok := t.Underlying().(*types.Struct)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
field := structType.Field(idx)
|
||||
if !yield(field, isPtr) {
|
||||
break
|
||||
}
|
||||
t = field.Type()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1397,7 +1397,7 @@ golang.org/x/text/width
|
||||
# golang.org/x/time v0.15.0
|
||||
## explicit; go 1.25.0
|
||||
golang.org/x/time/rate
|
||||
# golang.org/x/tools v0.45.0
|
||||
# golang.org/x/tools v0.46.0
|
||||
## explicit; go 1.25.0
|
||||
golang.org/x/tools/cmd/stringer
|
||||
golang.org/x/tools/go/ast/edge
|
||||
|
||||
Reference in New Issue
Block a user