Skip to content

Commit d0d86e4

Browse files
adonovangopherbot
authored andcommitted
x/tools: run gopls/internal/analysis/gofix/main.go -fix
This inlines calls to a number of deprecated functions in both std and x/tools. Updates golang/go#32816 Change-Id: Id7f89983b1428fd3c042947dbecf07349f0bc134 Reviewed-on: https://go-review.googlesource.com/c/tools/+/649057 LUCI-TryBot-Result: Go LUCI <[email protected]> Commit-Queue: Alan Donovan <[email protected]> Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]>
1 parent 2f1b076 commit d0d86e4

File tree

19 files changed

+23
-31
lines changed

19 files changed

+23
-31
lines changed

Diff for: go/analysis/checker/checker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ func (act *Action) exportPackageFact(fact analysis.Fact) {
594594

595595
func factType(fact analysis.Fact) reflect.Type {
596596
t := reflect.TypeOf(fact)
597-
if t.Kind() != reflect.Ptr {
597+
if t.Kind() != reflect.Pointer {
598598
log.Fatalf("invalid Fact type: got %T, want pointer", fact)
599599
}
600600
return t

Diff for: go/analysis/passes/copylock/copylock.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ var lockerType *types.Interface
378378

379379
// Construct a sync.Locker interface type.
380380
func init() {
381-
nullary := types.NewSignature(nil, nil, nil, false) // func()
381+
nullary := types.NewSignatureType(nil, nil, nil, nil, nil, false) // func()
382382
methods := []*types.Func{
383383
types.NewFunc(token.NoPos, nil, "Lock", nullary),
384384
types.NewFunc(token.NoPos, nil, "Unlock", nullary),

Diff for: go/analysis/passes/unusedresult/unusedresult.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
130130
}
131131

132132
// func() string
133-
var sigNoArgsStringResult = types.NewSignature(nil, nil,
134-
types.NewTuple(types.NewParam(token.NoPos, nil, "", types.Typ[types.String])),
135-
false)
133+
var sigNoArgsStringResult = types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(types.NewParam(token.NoPos, nil, "", types.Typ[types.String])), false)
136134

137135
type stringSetFlag map[string]bool
138136

Diff for: go/analysis/validate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func Validate(analyzers []*Analyzer) error {
6363
return fmt.Errorf("fact type %s registered by two analyzers: %v, %v",
6464
t, a, prev)
6565
}
66-
if t.Kind() != reflect.Ptr {
66+
if t.Kind() != reflect.Pointer {
6767
return fmt.Errorf("%s: fact type %s is not a pointer", a, t)
6868
}
6969
factTypes[t] = a

Diff for: go/ast/astutil/rewrite.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ type application struct {
183183

184184
func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast.Node) {
185185
// convert typed nil into untyped nil
186-
if v := reflect.ValueOf(n); v.Kind() == reflect.Ptr && v.IsNil() {
186+
if v := reflect.ValueOf(n); v.Kind() == reflect.Pointer && v.IsNil() {
187187
n = nil
188188
}
189189

Diff for: go/callgraph/vta/propagation_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func testSuite() map[string]*vtaGraph {
203203
a := newNamedType("A")
204204
b := newNamedType("B")
205205
c := newNamedType("C")
206-
sig := types.NewSignature(nil, types.NewTuple(), types.NewTuple(), false)
206+
sig := types.NewSignatureType(nil, nil, nil, types.NewTuple(), types.NewTuple(), false)
207207

208208
f1 := &ssa.Function{Signature: sig}
209209
setName(f1, "F1")

Diff for: go/internal/gccgoimporter/parser.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ func (p *parser) parseNamedType(nlist []interface{}) types.Type {
619619
p.skipInlineBody()
620620
p.expectEOL()
621621

622-
sig := types.NewSignature(receiver, params, results, isVariadic)
622+
sig := types.NewSignatureType(receiver, nil, nil, params, results, isVariadic)
623623
nt.AddMethod(types.NewFunc(token.NoPos, pkg, name, sig))
624624
}
625625
}
@@ -800,7 +800,7 @@ func (p *parser) parseFunctionType(pkg *types.Package, nlist []interface{}) *typ
800800
params, isVariadic := p.parseParamList(pkg)
801801
results := p.parseResultList(pkg)
802802

803-
*t = *types.NewSignature(nil, params, results, isVariadic)
803+
*t = *types.NewSignatureType(nil, nil, nil, params, results, isVariadic)
804804
return t
805805
}
806806

Diff for: go/ssa/interp/reflect.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func reflectKind(t types.Type) reflect.Kind {
231231
case *types.Map:
232232
return reflect.Map
233233
case *types.Pointer:
234-
return reflect.Ptr
234+
return reflect.Pointer
235235
case *types.Slice:
236236
return reflect.Slice
237237
case *types.Struct:
@@ -510,7 +510,7 @@ func newMethod(pkg *ssa.Package, recvType types.Type, name string) *ssa.Function
510510
// that is needed is the "pointerness" of Recv.Type, and for
511511
// now, we'll set it to always be false since we're only
512512
// concerned with rtype. Encapsulate this better.
513-
sig := types.NewSignature(types.NewParam(token.NoPos, nil, "recv", recvType), nil, nil, false)
513+
sig := types.NewSignatureType(types.NewParam(token.NoPos, nil, "recv", recvType), nil, nil, nil, nil, false)
514514
fn := pkg.Prog.NewFunction(name, sig, "fake reflect method")
515515
fn.Pkg = pkg
516516
return fn

Diff for: go/ssa/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func makeLen(T types.Type) *Builtin {
195195
lenParams := types.NewTuple(anonVar(T))
196196
return &Builtin{
197197
name: "len",
198-
sig: types.NewSignature(nil, lenParams, lenResults, false),
198+
sig: types.NewSignatureType(nil, nil, nil, lenParams, lenResults, false),
199199
}
200200
}
201201

Diff for: go/ssa/wrappers.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ func (b *builder) buildWrapper(fn *Function) {
106106
var c Call
107107
c.Call.Value = &Builtin{
108108
name: "ssa:wrapnilchk",
109-
sig: types.NewSignature(nil,
110-
types.NewTuple(anonVar(fn.method.recv), anonVar(tString), anonVar(tString)),
111-
types.NewTuple(anonVar(fn.method.recv)), false),
109+
sig: types.NewSignatureType(nil, nil, nil, types.NewTuple(anonVar(fn.method.recv), anonVar(tString), anonVar(tString)), types.NewTuple(anonVar(fn.method.recv)), false),
112110
}
113111
c.Call.Args = []Value{
114112
v,
@@ -262,7 +260,7 @@ func createThunk(prog *Program, sel *selection) *Function {
262260
}
263261

264262
func changeRecv(s *types.Signature, recv *types.Var) *types.Signature {
265-
return types.NewSignature(recv, s.Params(), s.Results(), s.Variadic())
263+
return types.NewSignatureType(recv, nil, nil, s.Params(), s.Results(), s.Variadic())
266264
}
267265

268266
// A local version of *types.Selection.

Diff for: go/types/objectpath/objectpath_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func (unreachable) F() {} // not reachable in export data
308308
if err != nil {
309309
t.Fatal(err)
310310
}
311-
conf := types.Config{Importer: importer.For("source", nil)}
311+
conf := types.Config{Importer: importer.ForCompiler(token.NewFileSet(), "source", nil)}
312312
info := &types.Info{
313313
Defs: make(map[*ast.Ident]types.Object),
314314
}

Diff for: internal/astutil/clone.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func cloneNode(n ast.Node) ast.Node {
2525
}
2626
clone = func(x reflect.Value) reflect.Value {
2727
switch x.Kind() {
28-
case reflect.Ptr:
28+
case reflect.Pointer:
2929
if x.IsNil() {
3030
return x
3131
}

Diff for: internal/gcimporter/ureader_yes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
574574

575575
recv := types.NewVar(fn.Pos(), fn.Pkg(), "", named)
576576
typesinternal.SetVarKind(recv, typesinternal.RecvVar)
577-
methods[i] = types.NewFunc(fn.Pos(), fn.Pkg(), fn.Name(), types.NewSignature(recv, sig.Params(), sig.Results(), sig.Variadic()))
577+
methods[i] = types.NewFunc(fn.Pos(), fn.Pkg(), fn.Name(), types.NewSignatureType(recv, nil, nil, sig.Params(), sig.Results(), sig.Variadic()))
578578
}
579579

580580
embeds := make([]types.Type, iface.NumEmbeddeds())

Diff for: internal/refactor/inline/inline.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2981,7 +2981,7 @@ func replaceNode(root ast.Node, from, to ast.Node) {
29812981
var visit func(reflect.Value)
29822982
visit = func(v reflect.Value) {
29832983
switch v.Kind() {
2984-
case reflect.Ptr:
2984+
case reflect.Pointer:
29852985
if v.Interface() == from {
29862986
found = true
29872987

Diff for: internal/refactor/inline/inline_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ func deepHash(n ast.Node) any {
19771977
var visit func(reflect.Value)
19781978
visit = func(v reflect.Value) {
19791979
switch v.Kind() {
1980-
case reflect.Ptr:
1980+
case reflect.Pointer:
19811981
ptr := v.UnsafePointer()
19821982
writeUint64(uint64(uintptr(ptr)))
19831983
if !v.IsNil() {

Diff for: internal/tool/tool.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func addFlags(f *flag.FlagSet, field reflect.StructField, value reflect.Value) *
250250
child := value.Type().Field(i)
251251
v := value.Field(i)
252252
// make sure we have a pointer
253-
if v.Kind() != reflect.Ptr {
253+
if v.Kind() != reflect.Pointer {
254254
v = v.Addr()
255255
}
256256
// check if that field is a flag or contains flags
@@ -289,7 +289,7 @@ func addFlag(f *flag.FlagSet, value reflect.Value, flagName string, help string)
289289
func resolve(v reflect.Value) reflect.Value {
290290
for {
291291
switch v.Kind() {
292-
case reflect.Interface, reflect.Ptr:
292+
case reflect.Interface, reflect.Pointer:
293293
v = v.Elem()
294294
default:
295295
return v

Diff for: refactor/eg/match.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"log"
1414
"os"
1515
"reflect"
16-
17-
"golang.org/x/tools/go/ast/astutil"
1816
)
1917

2018
// matchExpr reports whether pattern x matches y.
@@ -229,7 +227,7 @@ func (tr *Transformer) matchWildcard(xobj *types.Var, y ast.Expr) bool {
229227

230228
// -- utilities --------------------------------------------------------
231229

232-
func unparen(e ast.Expr) ast.Expr { return astutil.Unparen(e) }
230+
func unparen(e ast.Expr) ast.Expr { return ast.Unparen(e) }
233231

234232
// isRef returns the object referred to by this (possibly qualified)
235233
// identifier, or nil if the node is not a referring identifier.

Diff for: refactor/eg/rewrite.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func (tr *Transformer) subst(env map[string]ast.Expr, pattern, pos reflect.Value
338338
}
339339
return v
340340

341-
case reflect.Ptr:
341+
case reflect.Pointer:
342342
v := reflect.New(p.Type()).Elem()
343343
if elem := p.Elem(); elem.IsValid() {
344344
v.Set(tr.subst(env, elem, pos).Addr())

Diff for: refactor/rename/util.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"runtime"
1515
"strings"
1616
"unicode"
17-
18-
"golang.org/x/tools/go/ast/astutil"
1917
)
2018

2119
func objectKind(obj types.Object) string {
@@ -93,7 +91,7 @@ func sameFile(x, y string) bool {
9391
return false
9492
}
9593

96-
func unparen(e ast.Expr) ast.Expr { return astutil.Unparen(e) }
94+
func unparen(e ast.Expr) ast.Expr { return ast.Unparen(e) }
9795

9896
func is[T any](x any) bool {
9997
_, ok := x.(T)

0 commit comments

Comments
 (0)