summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/tools/internal
diff options
context:
space:
mode:
authorLibravatar Daenney <git@noreply.sourcery.dny.nu>2025-07-18 11:56:40 +0200
committerLibravatar tobi <kipvandenbos@noreply.codeberg.org>2025-07-18 11:56:40 +0200
commiteb600819854039c8d89fb1d7000f301ad3c7d542 (patch)
tree267138dcdf3280e32ef4dde7b5a3355212bd0474 /vendor/golang.org/x/tools/internal
parent[feature] Add `avif` file support (#4331) (diff)
downloadgotosocial-eb600819854039c8d89fb1d7000f301ad3c7d542.tar.xz
[chore/deps] Upgrade to go-sqlite 0.27.1 (#4334)
# Description This brings some performance improvements and SQLite 3.50.3. ## Checklist Please put an x inside each checkbox to indicate that you've read and followed it: `[ ]` -> `[x]` If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want). - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [ ] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have not leveraged AI to create the proposed changes. - [ ] I/we have performed a self-review of added code. - [ ] I/we have written code that is legible and maintainable by others. - [ ] I/we have commented the added code, particularly in hard-to-understand areas. - [ ] I/we have made any necessary changes to documentation. - [ ] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [ ] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4334 Co-authored-by: Daenney <git@noreply.sourcery.dny.nu> Co-committed-by: Daenney <git@noreply.sourcery.dny.nu>
Diffstat (limited to 'vendor/golang.org/x/tools/internal')
-rw-r--r--vendor/golang.org/x/tools/internal/imports/fix.go9
-rw-r--r--vendor/golang.org/x/tools/internal/imports/imports.go2
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/directories.go2
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/lookup.go2
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/symbols.go4
-rw-r--r--vendor/golang.org/x/tools/internal/typesinternal/classify_call.go8
-rw-r--r--vendor/golang.org/x/tools/internal/typesinternal/types.go61
7 files changed, 51 insertions, 37 deletions
diff --git a/vendor/golang.org/x/tools/internal/imports/fix.go b/vendor/golang.org/x/tools/internal/imports/fix.go
index 89b96381c..50b6ca51a 100644
--- a/vendor/golang.org/x/tools/internal/imports/fix.go
+++ b/vendor/golang.org/x/tools/internal/imports/fix.go
@@ -27,12 +27,13 @@ import (
"unicode"
"unicode/utf8"
+ "maps"
+
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/gocommand"
"golang.org/x/tools/internal/gopathwalk"
"golang.org/x/tools/internal/stdlib"
- "maps"
)
// importToGroup is a list of functions which map from an import path to
@@ -290,8 +291,8 @@ func (p *pass) loadPackageNames(ctx context.Context, imports []*ImportInfo) erro
return nil
}
-// if there is a trailing major version, remove it
-func withoutVersion(nm string) string {
+// WithoutVersion removes a trailing major version, if there is one.
+func WithoutVersion(nm string) string {
if v := path.Base(nm); len(v) > 0 && v[0] == 'v' {
if _, err := strconv.Atoi(v[1:]); err == nil {
// this is, for instance, called with rand/v2 and returns rand
@@ -313,7 +314,7 @@ func (p *pass) importIdentifier(imp *ImportInfo) string {
}
known := p.knownPackages[imp.ImportPath]
if known != nil && known.Name != "" {
- return withoutVersion(known.Name)
+ return WithoutVersion(known.Name)
}
return ImportPathToAssumedName(imp.ImportPath)
}
diff --git a/vendor/golang.org/x/tools/internal/imports/imports.go b/vendor/golang.org/x/tools/internal/imports/imports.go
index 2215a1288..b5f5218b5 100644
--- a/vendor/golang.org/x/tools/internal/imports/imports.go
+++ b/vendor/golang.org/x/tools/internal/imports/imports.go
@@ -93,7 +93,7 @@ func FixImports(ctx context.Context, filename string, src []byte, goroot string,
// env is needed.
func ApplyFixes(fixes []*ImportFix, filename string, src []byte, opt *Options, extraMode parser.Mode) (formatted []byte, err error) {
// Don't use parse() -- we don't care about fragments or statement lists
- // here, and we need to work with unparseable files.
+ // here, and we need to work with unparsable files.
fileSet := token.NewFileSet()
parserMode := parser.SkipObjectResolution
if opt.Comments {
diff --git a/vendor/golang.org/x/tools/internal/modindex/directories.go b/vendor/golang.org/x/tools/internal/modindex/directories.go
index 1e1a02f23..2faa6ce0b 100644
--- a/vendor/golang.org/x/tools/internal/modindex/directories.go
+++ b/vendor/golang.org/x/tools/internal/modindex/directories.go
@@ -26,7 +26,7 @@ type directory struct {
syms []symbol
}
-// filterDirs groups the directories by import path,
+// byImportPath groups the directories by import path,
// sorting the ones with the same import path by semantic version,
// most recent first.
func byImportPath(dirs []Relpath) (map[string][]*directory, error) {
diff --git a/vendor/golang.org/x/tools/internal/modindex/lookup.go b/vendor/golang.org/x/tools/internal/modindex/lookup.go
index bd605e0d7..34e3673ff 100644
--- a/vendor/golang.org/x/tools/internal/modindex/lookup.go
+++ b/vendor/golang.org/x/tools/internal/modindex/lookup.go
@@ -75,7 +75,7 @@ func (ix *Index) Lookup(pkg, name string, prefix bool) []Candidate {
return nil // didn't find the package
}
var ans []Candidate
- // loc is the first entry for this package name, but there may be severeal
+ // loc is the first entry for this package name, but there may be several
for i := loc; i < len(ix.Entries); i++ {
e := ix.Entries[i]
if e.PkgName != pkg {
diff --git a/vendor/golang.org/x/tools/internal/modindex/symbols.go b/vendor/golang.org/x/tools/internal/modindex/symbols.go
index b918529d4..31a502c58 100644
--- a/vendor/golang.org/x/tools/internal/modindex/symbols.go
+++ b/vendor/golang.org/x/tools/internal/modindex/symbols.go
@@ -30,7 +30,7 @@ import (
type symbol struct {
pkg string // name of the symbols's package
name string // declared name
- kind string // T, C, V, or F, follwed by D if deprecated
+ kind string // T, C, V, or F, followed by D if deprecated
sig string // signature information, for F
}
@@ -110,7 +110,7 @@ func getFileExports(f *ast.File) []symbol {
// The only place a $ can occur seems to be in a struct tag, which
// can be an arbitrary string literal, and ExprString does not presently
// print struct tags. So for this to happen the type of a formal parameter
- // has to be a explict struct, e.g. foo(x struct{a int "$"}) and ExprString
+ // has to be a explicit struct, e.g. foo(x struct{a int "$"}) and ExprString
// would have to show the struct tag. Even testing for this case seems
// a waste of effort, but let's remember the possibility
if strings.Contains(tp, "$") {
diff --git a/vendor/golang.org/x/tools/internal/typesinternal/classify_call.go b/vendor/golang.org/x/tools/internal/typesinternal/classify_call.go
index 649c82b6b..3db2a135b 100644
--- a/vendor/golang.org/x/tools/internal/typesinternal/classify_call.go
+++ b/vendor/golang.org/x/tools/internal/typesinternal/classify_call.go
@@ -65,14 +65,16 @@ func ClassifyCall(info *types.Info, call *ast.CallExpr) CallKind {
if info.Types == nil {
panic("ClassifyCall: info.Types is nil")
}
- if info.Types[call.Fun].IsType() {
+ tv := info.Types[call.Fun]
+ if tv.IsType() {
return CallConversion
}
+ if tv.IsBuiltin() {
+ return CallBuiltin
+ }
obj := info.Uses[UsedIdent(info, call.Fun)]
// Classify the call by the type of the object, if any.
switch obj := obj.(type) {
- case *types.Builtin:
- return CallBuiltin
case *types.Func:
if interfaceMethod(obj) {
return CallInterface
diff --git a/vendor/golang.org/x/tools/internal/typesinternal/types.go b/vendor/golang.org/x/tools/internal/typesinternal/types.go
index cc244689e..a5cd7e8db 100644
--- a/vendor/golang.org/x/tools/internal/typesinternal/types.go
+++ b/vendor/golang.org/x/tools/internal/typesinternal/types.go
@@ -69,6 +69,34 @@ func NameRelativeTo(pkg *types.Package) types.Qualifier {
}
}
+// TypeNameFor returns the type name symbol for the specified type, if
+// it is a [*types.Alias], [*types.Named], [*types.TypeParam], or a
+// [*types.Basic] representing a type.
+//
+// For all other types, and for Basic types representing a builtin,
+// constant, or nil, it returns nil. Be careful not to convert the
+// resulting nil pointer to a [types.Object]!
+//
+// If t is the type of a constant, it may be an "untyped" type, which
+// has no TypeName. To access the name of such types (e.g. "untyped
+// int"), use [types.Basic.Name].
+func TypeNameFor(t types.Type) *types.TypeName {
+ switch t := t.(type) {
+ case *types.Alias:
+ return t.Obj()
+ case *types.Named:
+ return t.Obj()
+ case *types.TypeParam:
+ return t.Obj()
+ case *types.Basic:
+ // See issues #71886 and #66890 for some history.
+ if tname, ok := types.Universe.Lookup(t.Name()).(*types.TypeName); ok {
+ return tname
+ }
+ }
+ return nil
+}
+
// A NamedOrAlias is a [types.Type] that is named (as
// defined by the spec) and capable of bearing type parameters: it
// abstracts aliases ([types.Alias]) and defined types
@@ -77,7 +105,7 @@ func NameRelativeTo(pkg *types.Package) types.Qualifier {
// Every type declared by an explicit "type" declaration is a
// NamedOrAlias. (Built-in type symbols may additionally
// have type [types.Basic], which is not a NamedOrAlias,
-// though the spec regards them as "named".)
+// though the spec regards them as "named"; see [TypeNameFor].)
//
// NamedOrAlias cannot expose the Origin method, because
// [types.Alias.Origin] and [types.Named.Origin] have different
@@ -85,32 +113,15 @@ func NameRelativeTo(pkg *types.Package) types.Qualifier {
type NamedOrAlias interface {
types.Type
Obj() *types.TypeName
- // TODO(hxjiang): add method TypeArgs() *types.TypeList after stop supporting go1.22.
-}
-
-// TypeParams is a light shim around t.TypeParams().
-// (go/types.Alias).TypeParams requires >= 1.23.
-func TypeParams(t NamedOrAlias) *types.TypeParamList {
- switch t := t.(type) {
- case *types.Alias:
- return aliases.TypeParams(t)
- case *types.Named:
- return t.TypeParams()
- }
- return nil
+ TypeArgs() *types.TypeList
+ TypeParams() *types.TypeParamList
+ SetTypeParams(tparams []*types.TypeParam)
}
-// TypeArgs is a light shim around t.TypeArgs().
-// (go/types.Alias).TypeArgs requires >= 1.23.
-func TypeArgs(t NamedOrAlias) *types.TypeList {
- switch t := t.(type) {
- case *types.Alias:
- return aliases.TypeArgs(t)
- case *types.Named:
- return t.TypeArgs()
- }
- return nil
-}
+var (
+ _ NamedOrAlias = (*types.Alias)(nil)
+ _ NamedOrAlias = (*types.Named)(nil)
+)
// Origin returns the generic type of the Named or Alias type t if it
// is instantiated, otherwise it returns t.