mirror of
https://github.com/mjl-/mox.git
synced 2025-07-19 23:46:35 +03:00
update to latest golang.org/x dependencies
This commit is contained in:
5
vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go
generated
vendored
5
vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go
generated
vendored
@ -193,10 +193,7 @@ func Read(in io.Reader, fset *token.FileSet, imports map[string]*types.Package,
|
||||
return pkg, err
|
||||
|
||||
default:
|
||||
l := len(data)
|
||||
if l > 10 {
|
||||
l = 10
|
||||
}
|
||||
l := min(len(data), 10)
|
||||
return nil, fmt.Errorf("unexpected export data with prefix %q for path %s", string(data[:l]), path)
|
||||
}
|
||||
}
|
||||
|
2
vendor/golang.org/x/tools/go/packages/external.go
generated
vendored
2
vendor/golang.org/x/tools/go/packages/external.go
generated
vendored
@ -90,7 +90,7 @@ func findExternalDriver(cfg *Config) driver {
|
||||
const toolPrefix = "GOPACKAGESDRIVER="
|
||||
tool := ""
|
||||
for _, env := range cfg.Env {
|
||||
if val := strings.TrimPrefix(env, toolPrefix); val != env {
|
||||
if val, ok := strings.CutPrefix(env, toolPrefix); ok {
|
||||
tool = val
|
||||
}
|
||||
}
|
||||
|
83
vendor/golang.org/x/tools/go/types/typeutil/callee.go
generated
vendored
83
vendor/golang.org/x/tools/go/types/typeutil/callee.go
generated
vendored
@ -7,45 +7,23 @@ package typeutil
|
||||
import (
|
||||
"go/ast"
|
||||
"go/types"
|
||||
|
||||
"golang.org/x/tools/internal/typeparams"
|
||||
_ "unsafe" // for linkname
|
||||
)
|
||||
|
||||
// Callee returns the named target of a function call, if any:
|
||||
// a function, method, builtin, or variable.
|
||||
//
|
||||
// Functions and methods may potentially have type parameters.
|
||||
//
|
||||
// Note: for calls of instantiated functions and methods, Callee returns
|
||||
// the corresponding generic function or method on the generic type.
|
||||
func Callee(info *types.Info, call *ast.CallExpr) types.Object {
|
||||
fun := ast.Unparen(call.Fun)
|
||||
|
||||
// Look through type instantiation if necessary.
|
||||
isInstance := false
|
||||
switch fun.(type) {
|
||||
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]()`.
|
||||
isInstance = true
|
||||
fun, _, _, _ = typeparams.UnpackIndexExpr(fun)
|
||||
}
|
||||
|
||||
var obj types.Object
|
||||
switch fun := fun.(type) {
|
||||
case *ast.Ident:
|
||||
obj = info.Uses[fun] // type, var, builtin, or declared func
|
||||
case *ast.SelectorExpr:
|
||||
if sel, ok := info.Selections[fun]; ok {
|
||||
obj = sel.Obj() // method or field
|
||||
} else {
|
||||
obj = info.Uses[fun.Sel] // qualified identifier?
|
||||
}
|
||||
obj := info.Uses[usedIdent(info, call.Fun)]
|
||||
if obj == nil {
|
||||
return nil
|
||||
}
|
||||
if _, ok := obj.(*types.TypeName); ok {
|
||||
return nil // T(x) is a conversion, not a call
|
||||
}
|
||||
// A Func is required to match instantiations.
|
||||
if _, ok := obj.(*types.Func); isInstance && !ok {
|
||||
return nil // Was not a Func.
|
||||
return nil
|
||||
}
|
||||
return obj
|
||||
}
|
||||
@ -56,13 +34,52 @@ func Callee(info *types.Info, call *ast.CallExpr) types.Object {
|
||||
// Note: for calls of instantiated functions and methods, StaticCallee returns
|
||||
// the corresponding generic function or method on the generic type.
|
||||
func StaticCallee(info *types.Info, call *ast.CallExpr) *types.Func {
|
||||
if f, ok := Callee(info, call).(*types.Func); ok && !interfaceMethod(f) {
|
||||
return f
|
||||
obj := info.Uses[usedIdent(info, call.Fun)]
|
||||
fn, _ := obj.(*types.Func)
|
||||
if fn == nil || interfaceMethod(fn) {
|
||||
return nil
|
||||
}
|
||||
return fn
|
||||
}
|
||||
|
||||
// usedIdent is the implementation of [internal/typesinternal.UsedIdent].
|
||||
// It returns the identifier associated with e.
|
||||
// See typesinternal.UsedIdent for a fuller description.
|
||||
// This function should live in typesinternal, but cannot because it would
|
||||
// create an import cycle.
|
||||
//
|
||||
//go:linkname usedIdent
|
||||
func usedIdent(info *types.Info, e ast.Expr) *ast.Ident {
|
||||
if info.Types == nil || info.Uses == nil {
|
||||
panic("one of info.Types or info.Uses is nil; both must be populated")
|
||||
}
|
||||
// Look through type instantiation if necessary.
|
||||
switch d := ast.Unparen(e).(type) {
|
||||
case *ast.IndexExpr:
|
||||
if info.Types[d.Index].IsType() {
|
||||
e = d.X
|
||||
}
|
||||
case *ast.IndexListExpr:
|
||||
e = d.X
|
||||
}
|
||||
|
||||
switch e := ast.Unparen(e).(type) {
|
||||
// info.Uses always has the object we want, even for selector expressions.
|
||||
// We don't need info.Selections.
|
||||
// See go/types/recording.go:recordSelection.
|
||||
case *ast.Ident:
|
||||
return e
|
||||
case *ast.SelectorExpr:
|
||||
return e.Sel
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// interfaceMethod reports whether its argument is a method of an interface.
|
||||
// This function should live in typesinternal, but cannot because it would create an import cycle.
|
||||
//
|
||||
//go:linkname interfaceMethod
|
||||
func interfaceMethod(f *types.Func) bool {
|
||||
recv := f.Type().(*types.Signature).Recv()
|
||||
recv := f.Signature().Recv()
|
||||
return recv != nil && types.IsInterface(recv.Type())
|
||||
}
|
||||
|
Reference in New Issue
Block a user