aboutsummaryrefslogtreecommitdiff
path: root/src/go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-12-01 12:15:45 -0500
committerRuss Cox <rsc@golang.org>2021-12-13 18:45:54 +0000
commit2580d0e08d5e9f979b943758d3c49877fb2324cb (patch)
tree3aafccfd81087734156a1778ce2321adf345f271 /src/go
parent083ef5462494e81ee23316245c5d65085a3f62d9 (diff)
downloadgo-2580d0e08d5e9f979b943758d3c49877fb2324cb.tar.gz
go-2580d0e08d5e9f979b943758d3c49877fb2324cb.zip
all: gofmt -w -r 'interface{} -> any' src
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/go')
-rw-r--r--src/go/ast/print.go18
-rw-r--r--src/go/ast/print_test.go2
-rw-r--r--src/go/ast/resolve.go2
-rw-r--r--src/go/ast/scope.go8
-rw-r--r--src/go/constant/value.go4
-rw-r--r--src/go/constant/value_test.go4
-rw-r--r--src/go/doc/doc.go2
-rw-r--r--src/go/doc/doc_test.go2
-rw-r--r--src/go/doc/testdata/benchmark.go4
-rw-r--r--src/go/doc/testdata/testing.0.golden24
-rw-r--r--src/go/doc/testdata/testing.1.golden40
-rw-r--r--src/go/doc/testdata/testing.2.golden24
-rw-r--r--src/go/doc/testdata/testing.go20
-rw-r--r--src/go/format/format.go2
-rw-r--r--src/go/internal/gccgoimporter/parser.go32
-rw-r--r--src/go/internal/gcimporter/gcimporter_test.go2
-rw-r--r--src/go/internal/gcimporter/support.go2
-rw-r--r--src/go/internal/gcimporter/testdata/exports.go6
-rw-r--r--src/go/parser/error_test.go2
-rw-r--r--src/go/parser/interface.go6
-rw-r--r--src/go/parser/parser.go2
-rw-r--r--src/go/parser/resolver.go6
-rw-r--r--src/go/printer/printer.go14
-rw-r--r--src/go/printer/testdata/parser.go4
-rw-r--r--src/go/scanner/scanner.go2
-rw-r--r--src/go/token/serialize.go4
-rw-r--r--src/go/token/serialize_test.go4
-rw-r--r--src/go/types/check.go4
-rw-r--r--src/go/types/conversions.go2
-rw-r--r--src/go/types/errors.go20
-rw-r--r--src/go/types/eval_test.go4
-rw-r--r--src/go/types/expr.go4
-rw-r--r--src/go/types/gotype.go2
-rw-r--r--src/go/types/hilbert_test.go2
-rw-r--r--src/go/types/initorder.go4
-rw-r--r--src/go/types/instantiate.go2
-rw-r--r--src/go/types/operand.go2
-rw-r--r--src/go/types/sizeof_test.go6
-rw-r--r--src/go/types/stdlib_test.go4
-rw-r--r--src/go/types/stmt.go4
-rw-r--r--src/go/types/subst.go4
41 files changed, 153 insertions, 153 deletions
diff --git a/src/go/ast/print.go b/src/go/ast/print.go
index b58683075c..85e6943928 100644
--- a/src/go/ast/print.go
+++ b/src/go/ast/print.go
@@ -36,17 +36,17 @@ func NotNilFilter(_ string, v reflect.Value) bool {
// struct fields for which f(fieldname, fieldvalue) is true are
// printed; all others are filtered from the output. Unexported
// struct fields are never printed.
-func Fprint(w io.Writer, fset *token.FileSet, x interface{}, f FieldFilter) error {
+func Fprint(w io.Writer, fset *token.FileSet, x any, f FieldFilter) error {
return fprint(w, fset, x, f)
}
-func fprint(w io.Writer, fset *token.FileSet, x interface{}, f FieldFilter) (err error) {
+func fprint(w io.Writer, fset *token.FileSet, x any, f FieldFilter) (err error) {
// setup printer
p := printer{
output: w,
fset: fset,
filter: f,
- ptrmap: make(map[interface{}]int),
+ ptrmap: make(map[any]int),
last: '\n', // force printing of line number on first line
}
@@ -70,7 +70,7 @@ func fprint(w io.Writer, fset *token.FileSet, x interface{}, f FieldFilter) (err
// Print prints x to standard output, skipping nil fields.
// Print(fset, x) is the same as Fprint(os.Stdout, fset, x, NotNilFilter).
-func Print(fset *token.FileSet, x interface{}) error {
+func Print(fset *token.FileSet, x any) error {
return Fprint(os.Stdout, fset, x, NotNilFilter)
}
@@ -78,10 +78,10 @@ type printer struct {
output io.Writer
fset *token.FileSet
filter FieldFilter
- ptrmap map[interface{}]int // *T -> line number
- indent int // current indentation level
- last byte // the last byte processed by Write
- line int // current line number
+ ptrmap map[any]int // *T -> line number
+ indent int // current indentation level
+ last byte // the last byte processed by Write
+ line int // current line number
}
var indent = []byte(". ")
@@ -125,7 +125,7 @@ type localError struct {
}
// printf is a convenience wrapper that takes care of print errors.
-func (p *printer) printf(format string, args ...interface{}) {
+func (p *printer) printf(format string, args ...any) {
if _, err := fmt.Fprintf(p, format, args...); err != nil {
panic(localError{err})
}
diff --git a/src/go/ast/print_test.go b/src/go/ast/print_test.go
index 210f164301..6691ccd63a 100644
--- a/src/go/ast/print_test.go
+++ b/src/go/ast/print_test.go
@@ -11,7 +11,7 @@ import (
)
var tests = []struct {
- x interface{} // x is printed as s
+ x any // x is printed as s
s string
}{
// basic types
diff --git a/src/go/ast/resolve.go b/src/go/ast/resolve.go
index c1830b5e4d..126a27b18c 100644
--- a/src/go/ast/resolve.go
+++ b/src/go/ast/resolve.go
@@ -22,7 +22,7 @@ func (p *pkgBuilder) error(pos token.Pos, msg string) {
p.errors.Add(p.fset.Position(pos), msg)
}
-func (p *pkgBuilder) errorf(pos token.Pos, format string, args ...interface{}) {
+func (p *pkgBuilder) errorf(pos token.Pos, format string, args ...any) {
p.error(pos, fmt.Sprintf(format, args...))
}
diff --git a/src/go/ast/scope.go b/src/go/ast/scope.go
index a400c7152a..d24a5f0e00 100644
--- a/src/go/ast/scope.go
+++ b/src/go/ast/scope.go
@@ -75,10 +75,10 @@ func (s *Scope) String() string {
//
type Object struct {
Kind ObjKind
- Name string // declared name
- Decl interface{} // corresponding Field, XxxSpec, FuncDecl, LabeledStmt, AssignStmt, Scope; or nil
- Data interface{} // object-specific data; or nil
- Type interface{} // placeholder for type information; may be nil
+ Name string // declared name
+ Decl any // corresponding Field, XxxSpec, FuncDecl, LabeledStmt, AssignStmt, Scope; or nil
+ Data any // object-specific data; or nil
+ Type any // placeholder for type information; may be nil
}
// NewObj creates a new object of a given kind and name.
diff --git a/src/go/constant/value.go b/src/go/constant/value.go
index 014e873100..dee3bce9ee 100644
--- a/src/go/constant/value.go
+++ b/src/go/constant/value.go
@@ -579,7 +579,7 @@ func Float64Val(x Value) (float64, bool) {
// Float *big.Float or *big.Rat
// everything else nil
//
-func Val(x Value) interface{} {
+func Val(x Value) any {
switch x := x.(type) {
case boolVal:
return bool(x)
@@ -610,7 +610,7 @@ func Val(x Value) interface{} {
// *big.Rat Float
// anything else Unknown
//
-func Make(x interface{}) Value {
+func Make(x any) Value {
switch x := x.(type) {
case bool:
return boolVal(x)
diff --git a/src/go/constant/value_test.go b/src/go/constant/value_test.go
index ac179b3d8c..e41315ee27 100644
--- a/src/go/constant/value_test.go
+++ b/src/go/constant/value_test.go
@@ -659,10 +659,10 @@ func TestMakeFloat64(t *testing.T) {
type makeTestCase struct {
kind Kind
- arg, want interface{}
+ arg, want any
}
-func dup(k Kind, x interface{}) makeTestCase { return makeTestCase{k, x, x} }
+func dup(k Kind, x any) makeTestCase { return makeTestCase{k, x, x} }
func TestMake(t *testing.T) {
for _, test := range []makeTestCase{
diff --git a/src/go/doc/doc.go b/src/go/doc/doc.go
index 79d38998e7..5ab854d084 100644
--- a/src/go/doc/doc.go
+++ b/src/go/doc/doc.go
@@ -157,7 +157,7 @@ func New(pkg *ast.Package, importPath string, mode Mode) *Package {
// NewFromFiles takes ownership of the AST files and may edit them,
// unless the PreserveAST Mode bit is on.
//
-func NewFromFiles(fset *token.FileSet, files []*ast.File, importPath string, opts ...interface{}) (*Package, error) {
+func NewFromFiles(fset *token.FileSet, files []*ast.File, importPath string, opts ...any) (*Package, error) {
// Check for invalid API usage.
if fset == nil {
panic(fmt.Errorf("doc.NewFromFiles: no token.FileSet provided (fset == nil)"))
diff --git a/src/go/doc/doc_test.go b/src/go/doc/doc_test.go
index cbdca62aa1..3d17036f01 100644
--- a/src/go/doc/doc_test.go
+++ b/src/go/doc/doc_test.go
@@ -38,7 +38,7 @@ func readTemplate(filename string) *template.Template {
return template.Must(t.ParseFiles(filepath.Join(dataDir, filename)))
}
-func nodeFmt(node interface{}, fset *token.FileSet) string {
+func nodeFmt(node any, fset *token.FileSet) string {
var buf bytes.Buffer
printer.Fprint(&buf, fset, node)
return strings.ReplaceAll(strings.TrimSpace(buf.String()), "\n", "\n\t")
diff --git a/src/go/doc/testdata/benchmark.go b/src/go/doc/testdata/benchmark.go
index 1d581f057e..d27bf116aa 100644
--- a/src/go/doc/testdata/benchmark.go
+++ b/src/go/doc/testdata/benchmark.go
@@ -232,7 +232,7 @@ func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks [
runtime.GOMAXPROCS(procs)
b := &B{
common: common{
- signal: make(chan interface{}),
+ signal: make(chan any),
},
benchmark: Benchmark,
}
@@ -285,7 +285,7 @@ func (b *B) trimOutput() {
func Benchmark(f func(b *B)) BenchmarkResult {
b := &B{
common: common{
- signal: make(chan interface{}),
+ signal: make(chan any),
},
benchmark: InternalBenchmark{"", f},
}
diff --git a/src/go/doc/testdata/testing.0.golden b/src/go/doc/testdata/testing.0.golden
index 83cf37cd3a..61dac8bb66 100644
--- a/src/go/doc/testdata/testing.0.golden
+++ b/src/go/doc/testdata/testing.0.golden
@@ -46,10 +46,10 @@ TYPES
}
// Error is equivalent to Log() followed by Fail().
- func (c *B) Error(args ...interface{})
+ func (c *B) Error(args ...any)
// Errorf is equivalent to Logf() followed by Fail().
- func (c *B) Errorf(format string, args ...interface{})
+ func (c *B) Errorf(format string, args ...any)
// Fail marks the function as having failed but continues ...
func (c *B) Fail()
@@ -61,16 +61,16 @@ TYPES
func (c *B) Failed() bool
// Fatal is equivalent to Log() followed by FailNow().
- func (c *B) Fatal(args ...interface{})
+ func (c *B) Fatal(args ...any)
// Fatalf is equivalent to Logf() followed by FailNow().
- func (c *B) Fatalf(format string, args ...interface{})
+ func (c *B) Fatalf(format string, args ...any)
// Log formats its arguments using default formatting, analogous ...
- func (c *B) Log(args ...interface{})
+ func (c *B) Log(args ...any)
// Logf formats its arguments according to the format, analogous ...
- func (c *B) Logf(format string, args ...interface{})
+ func (c *B) Logf(format string, args ...any)
// ResetTimer sets the elapsed benchmark time to zero. It does not ...
func (b *B) ResetTimer()
@@ -125,10 +125,10 @@ TYPES
}
// Error is equivalent to Log() followed by Fail().
- func (c *T) Error(args ...interface{})
+ func (c *T) Error(args ...any)
// Errorf is equivalent to Logf() followed by Fail().
- func (c *T) Errorf(format string, args ...interface{})
+ func (c *T) Errorf(format string, args ...any)
// Fail marks the function as having failed but continues ...
func (c *T) Fail()
@@ -140,16 +140,16 @@ TYPES
func (c *T) Failed() bool
// Fatal is equivalent to Log() followed by FailNow().
- func (c *T) Fatal(args ...interface{})
+ func (c *T) Fatal(args ...any)
// Fatalf is equivalent to Logf() followed by FailNow().
- func (c *T) Fatalf(format string, args ...interface{})
+ func (c *T) Fatalf(format string, args ...any)
// Log formats its arguments using default formatting, analogous ...
- func (c *T) Log(args ...interface{})
+ func (c *T) Log(args ...any)
// Logf formats its arguments according to the format, analogous ...
- func (c *T) Logf(format string, args ...interface{})
+ func (c *T) Logf(format string, args ...any)
// Parallel signals that this test is to be run in parallel with ...
func (t *T) Parallel()
diff --git a/src/go/doc/testdata/testing.1.golden b/src/go/doc/testdata/testing.1.golden
index b9d14517a9..1655af11a8 100644
--- a/src/go/doc/testdata/testing.1.golden
+++ b/src/go/doc/testdata/testing.1.golden
@@ -119,10 +119,10 @@ TYPES
}
// Error is equivalent to Log() followed by Fail().
- func (c *B) Error(args ...interface{})
+ func (c *B) Error(args ...any)
// Errorf is equivalent to Logf() followed by Fail().
- func (c *B) Errorf(format string, args ...interface{})
+ func (c *B) Errorf(format string, args ...any)
// Fail marks the function as having failed but continues ...
func (c *B) Fail()
@@ -134,16 +134,16 @@ TYPES
func (c *B) Failed() bool
// Fatal is equivalent to Log() followed by FailNow().
- func (c *B) Fatal(args ...interface{})
+ func (c *B) Fatal(args ...any)
// Fatalf is equivalent to Logf() followed by FailNow().
- func (c *B) Fatalf(format string, args ...interface{})
+ func (c *B) Fatalf(format string, args ...any)
// Log formats its arguments using default formatting, analogous ...
- func (c *B) Log(args ...interface{})
+ func (c *B) Log(args ...any)
// Logf formats its arguments according to the format, analogous ...
- func (c *B) Logf(format string, args ...interface{})
+ func (c *B) Logf(format string, args ...any)
// ResetTimer sets the elapsed benchmark time to zero. It does not ...
func (b *B) ResetTimer()
@@ -221,10 +221,10 @@ TYPES
}
// Error is equivalent to Log() followed by Fail().
- func (c *T) Error(args ...interface{})
+ func (c *T) Error(args ...any)
// Errorf is equivalent to Logf() followed by Fail().
- func (c *T) Errorf(format string, args ...interface{})
+ func (c *T) Errorf(format string, args ...any)
// Fail marks the function as having failed but continues ...
func (c *T) Fail()
@@ -236,16 +236,16 @@ TYPES
func (c *T) Failed() bool
// Fatal is equivalent to Log() followed by FailNow().
- func (c *T) Fatal(args ...interface{})
+ func (c *T) Fatal(args ...any)
// Fatalf is equivalent to Logf() followed by FailNow().
- func (c *T) Fatalf(format string, args ...interface{})
+ func (c *T) Fatalf(format string, args ...any)
// Log formats its arguments using default formatting, analogous ...
- func (c *T) Log(args ...interface{})
+ func (c *T) Log(args ...any)
// Logf formats its arguments according to the format, analogous ...
- func (c *T) Logf(format string, args ...interface{})
+ func (c *T) Logf(format string, args ...any)
// Parallel signals that this test is to be run in parallel with ...
func (t *T) Parallel()
@@ -262,15 +262,15 @@ TYPES
failed bool // Test or benchmark has failed.
start time.Time // Time test or benchmark started
duration time.Duration
- self interface{} // To be sent on signal channel when done.
- signal chan interface{} // Output for serial tests.
+ self any // To be sent on signal channel when done.
+ signal chan any // Output for serial tests.
}
// Error is equivalent to Log() followed by Fail().
- func (c *common) Error(args ...interface{})
+ func (c *common) Error(args ...any)
// Errorf is equivalent to Logf() followed by Fail().
- func (c *common) Errorf(format string, args ...interface{})
+ func (c *common) Errorf(format string, args ...any)
// Fail marks the function as having failed but continues ...
func (c *common) Fail()
@@ -282,16 +282,16 @@ TYPES
func (c *common) Failed() bool
// Fatal is equivalent to Log() followed by FailNow().
- func (c *common) Fatal(args ...interface{})
+ func (c *common) Fatal(args ...any)
// Fatalf is equivalent to Logf() followed by FailNow().
- func (c *common) Fatalf(format string, args ...interface{})
+ func (c *common) Fatalf(format string, args ...any)
// Log formats its arguments using default formatting, analogous ...
- func (c *common) Log(args ...interface{})
+ func (c *common) Log(args ...any)
// Logf formats its arguments according to the format, analogous ...
- func (c *common) Logf(format string, args ...interface{})
+ func (c *common) Logf(format string, args ...any)
// log generates the output. It's always at the same stack depth.
func (c *common) log(s string)
diff --git a/src/go/doc/testdata/testing.2.golden b/src/go/doc/testdata/testing.2.golden
index 83cf37cd3a..61dac8bb66 100644
--- a/src/go/doc/testdata/testing.2.golden
+++ b/src/go/doc/testdata/testing.2.golden
@@ -46,10 +46,10 @@ TYPES
}
// Error is equivalent to Log() followed by Fail().
- func (c *B) Error(args ...interface{})
+ func (c *B) Error(args ...any)
// Errorf is equivalent to Logf() followed by Fail().
- func (c *B) Errorf(format string, args ...interface{})
+ func (c *B) Errorf(format string, args ...any)
// Fail marks the function as having failed but continues ...
func (c *B) Fail()
@@ -61,16 +61,16 @@ TYPES
func (c *B) Failed() bool
// Fatal is equivalent to Log() followed by FailNow().
- func (c *B) Fatal(args ...interface{})
+ func (c *B) Fatal(args ...any)
// Fatalf is equivalent to Logf() followed by FailNow().
- func (c *B) Fatalf(format string, args ...interface{})
+ func (c *B) Fatalf(format string, args ...any)
// Log formats its arguments using default formatting, analogous ...
- func (c *B) Log(args ...interface{})
+ func (c *B) Log(args ...any)
// Logf formats its arguments according to the format, analogous ...
- func (c *B) Logf(format string, args ...interface{})
+ func (c *B) Logf(format string, args ...any)
// ResetTimer sets the elapsed benchmark time to zero. It does not ...
func (b *B) ResetTimer()
@@ -125,10 +125,10 @@ TYPES
}
// Error is equivalent to Log() followed by Fail().
- func (c *T) Error(args ...interface{})
+ func (c *T) Error(args ...any)
// Errorf is equivalent to Logf() followed by Fail().
- func (c *T) Errorf(format string, args ...interface{})
+ func (c *T) Errorf(format string, args ...any)
// Fail marks the function as having failed but continues ...
func (c *T) Fail()
@@ -140,16 +140,16 @@ TYPES
func (c *T) Failed() bool
// Fatal is equivalent to Log() followed by FailNow().
- func (c *T) Fatal(args ...interface{})
+ func (c *T) Fatal(args ...any)
// Fatalf is equivalent to Logf() followed by FailNow().
- func (c *T) Fatalf(format string, args ...interface{})
+ func (c *T) Fatalf(format string, args ...any)
// Log formats its arguments using default formatting, analogous ...
- func (c *T) Log(args ...interface{})
+ func (c *T) Log(args ...any)
// Logf formats its arguments according to the format, analogous ...
- func (c *T) Logf(format string, args ...interface{})
+ func (c *T) Logf(format string, args ...any)
// Parallel signals that this test is to be run in parallel with ...
func (t *T) Parallel()
diff --git a/src/go/doc/testdata/testing.go b/src/go/doc/testdata/testing.go
index 52810f7a56..80238df283 100644
--- a/src/go/doc/testdata/testing.go
+++ b/src/go/doc/testdata/testing.go
@@ -77,8 +77,8 @@ type common struct {
failed bool // Test or benchmark has failed.
start time.Time // Time test or benchmark started
duration time.Duration
- self interface{} // To be sent on signal channel when done.
- signal chan interface{} // Output for serial tests.
+ self any // To be sent on signal channel when done.
+ signal chan any // Output for serial tests.
}
// Short reports whether the -test.short flag is set.
@@ -167,32 +167,32 @@ func (c *common) log(s string) {
// Log formats its arguments using default formatting, analogous to Println(),
// and records the text in the error log.
-func (c *common) Log(args ...interface{}) { c.log(fmt.Sprintln(args...)) }
+func (c *common) Log(args ...any) { c.log(fmt.Sprintln(args...)) }
// Logf formats its arguments according to the format, analogous to Printf(),
// and records the text in the error log.
-func (c *common) Logf(format string, args ...interface{}) { c.log(fmt.Sprintf(format, args...)) }
+func (c *common) Logf(format string, args ...any) { c.log(fmt.Sprintf(format, args...)) }
// Error is equivalent to Log() followed by Fail().
-func (c *common) Error(args ...interface{}) {
+func (c *common) Error(args ...any) {
c.log(fmt.Sprintln(args...))
c.Fail()
}
// Errorf is equivalent to Logf() followed by Fail().
-func (c *common) Errorf(format string, args ...interface{}) {
+func (c *common) Errorf(format string, args ...any) {
c.log(fmt.Sprintf(format, args...))
c.Fail()
}
// Fatal is equivalent to Log() followed by FailNow().
-func (c *common) Fatal(args ...interface{}) {
+func (c *common) Fatal(args ...any) {
c.log(fmt.Sprintln(args...))
c.FailNow()
}
// Fatalf is equivalent to Logf() followed by FailNow().
-func (c *common) Fatalf(format string, args ...interface{}) {
+func (c *common) Fatalf(format string, args ...any) {
c.log(fmt.Sprintf(format, args...))
c.FailNow()
}
@@ -269,7 +269,7 @@ func RunTests(matchString func(pat, str string) (bool, error), tests []InternalT
// If all tests pump to the same channel, a bug can occur where a test
// kicks off a goroutine that Fails, yet the test still delivers a completion signal,
// which skews the counting.
- var collector = make(chan interface{})
+ var collector = make(chan any)
numParallel := 0
startParallel := make(chan bool)
@@ -289,7 +289,7 @@ func RunTests(matchString func(pat, str string) (bool, error), tests []InternalT
}
t := &T{
common: common{
- signal: make(chan interface{}),
+ signal: make(chan any),
},
name: testName,
startParallel: startParallel,
diff --git a/src/go/format/format.go b/src/go/format/format.go
index a603d9630e..ea8dd20823 100644
--- a/src/go/format/format.go
+++ b/src/go/format/format.go
@@ -51,7 +51,7 @@ const parserMode = parser.ParseComments
// The function may return early (before the entire result is written)
// and return a formatting error, for instance due to an incorrect AST.
//
-func Node(dst io.Writer, fset *token.FileSet, node interface{}) error {
+func Node(dst io.Writer, fset *token.FileSet, node any) error {
// Determine if we have a complete source file (file != nil).
var file *ast.File
var cnode *printer.CommentedNode
diff --git a/src/go/internal/gccgoimporter/parser.go b/src/go/internal/gccgoimporter/parser.go
index 267c9953e4..48335fa6d8 100644
--- a/src/go/internal/gccgoimporter/parser.go
+++ b/src/go/internal/gccgoimporter/parser.go
@@ -80,7 +80,7 @@ func (e importError) Error() string {
return fmt.Sprintf("import error %s (byte offset = %d): %s", e.pos, e.pos.Offset, e.err)
}
-func (p *parser) error(err interface{}) {
+func (p *parser) error(err any) {
if s, ok := err.(string); ok {
err = errors.New(s)
}
@@ -88,7 +88,7 @@ func (p *parser) error(err interface{}) {
panic(importError{p.scanner.Pos(), err.(error)})
}
-func (p *parser) errorf(format string, args ...interface{}) {
+func (p *parser) errorf(format string, args ...any) {
p.error(fmt.Errorf(format, args...))
}
@@ -474,7 +474,7 @@ func (p *parser) reserve(n int) {
// used to resolve named types, or it can be a *types.Pointer,
// used to resolve pointers to named types in case they are referenced
// by embedded fields.
-func (p *parser) update(t types.Type, nlist []interface{}) {
+func (p *parser) update(t types.Type, nlist []any) {
if t == reserved {
p.errorf("internal error: update(%v) invoked on reserved", nlist)
}
@@ -509,7 +509,7 @@ func (p *parser) update(t types.Type, nlist []interface{}) {
// NamedType = TypeName [ "=" ] Type { Method } .
// TypeName = ExportedName .
// Method = "func" "(" Param ")" Name ParamList ResultList [InlineBody] ";" .
-func (p *parser) parseNamedType(nlist []interface{}) types.Type {
+func (p *parser) parseNamedType(nlist []any) types.Type {
pkg, name := p.parseExportedName()
scope := pkg.Scope()
obj := scope.Lookup(name)
@@ -626,7 +626,7 @@ func (p *parser) parseInt() int {
}
// ArrayOrSliceType = "[" [ int ] "]" Type .
-func (p *parser) parseArrayOrSliceType(pkg *types.Package, nlist []interface{}) types.Type {
+func (p *parser) parseArrayOrSliceType(pkg *types.Package, nlist []any) types.Type {
p.expect('[')
if p.tok == ']' {
p.next()
@@ -649,7 +649,7 @@ func (p *parser) parseArrayOrSliceType(pkg *types.Package, nlist []interface{})
}
// MapType = "map" "[" Type "]" Type .
-func (p *parser) parseMapType(pkg *types.Package, nlist []interface{}) types.Type {
+func (p *parser) parseMapType(pkg *types.Package, nlist []any) types.Type {
p.expectKeyword("map")
t := new(types.Map)
@@ -665,7 +665,7 @@ func (p *parser) parseMapType(pkg *types.Package, nlist []interface{}) types.Typ
}
// ChanType = "chan" ["<-" | "-<"] Type .
-func (p *parser) parseChanType(pkg *types.Package, nlist []interface{}) types.Type {
+func (p *parser) parseChanType(pkg *types.Package, nlist []any) types.Type {
p.expectKeyword("chan")
t := new(types.Chan)
@@ -692,7 +692,7 @@ func (p *parser) parseChanType(pkg *types.Package, nlist []interface{}) types.Ty
}
// StructType = "struct" "{" { Field } "}" .
-func (p *parser) parseStructType(pkg *types.Package, nlist []interface{}) types.Type {
+func (p *parser) parseStructType(pkg *types.Package, nlist []any) types.Type {
p.expectKeyword("struct")
t := new(types.Struct)
@@ -759,7 +759,7 @@ func (p *parser) parseResultList(pkg *types.Package) *types.Tuple {
}
// FunctionType = ParamList ResultList .
-func (p *parser) parseFunctionType(pkg *types.Package, nlist []interface{}) *types.Signature {
+func (p *parser) parseFunctionType(pkg *types.Package, nlist []any) *types.Signature {
t := new(types.Signature)
p.update(t, nlist)
@@ -799,7 +799,7 @@ func (p *parser) parseFunc(pkg *types.Package) *types.Func {
}
// InterfaceType = "interface" "{" { ("?" Type | Func) ";" } "}" .
-func (p *parser) parseInterfaceType(pkg *types.Package, nlist []interface{}) types.Type {
+func (p *parser) parseInterfaceType(pkg *types.Package, nlist []any) types.Type {
p.expectKeyword("interface")
t := new(types.Interface)
@@ -828,7 +828,7 @@ func (p *parser) parseInterfaceType(pkg *types.Package, nlist []interface{}) typ
}
// PointerType = "*" ("any" | Type) .
-func (p *parser) parsePointerType(pkg *types.Package, nlist []interface{}) types.Type {
+func (p *parser) parsePointerType(pkg *types.Package, nlist []any) types.Type {
p.expect('*')
if p.tok == scanner.Ident {
p.expectKeyword("any")
@@ -846,7 +846,7 @@ func (p *parser) parsePointerType(pkg *types.Package, nlist []interface{}) types
}
// TypeSpec = NamedType | MapType | ChanType | StructType | InterfaceType | PointerType | ArrayOrSliceType | FunctionType .
-func (p *parser) parseTypeSpec(pkg *types.Package, nlist []interface{}) types.Type {
+func (p *parser) parseTypeSpec(pkg *types.Package, nlist []any) types.Type {
switch p.tok {
case scanner.String:
return p.parseNamedType(nlist)
@@ -935,14 +935,14 @@ func lookupBuiltinType(typ int) types.Type {
//
// parseType updates the type map to t for all type numbers n.
//
-func (p *parser) parseType(pkg *types.Package, n ...interface{}) types.Type {
+func (p *parser) parseType(pkg *types.Package, n ...any) types.Type {
p.expect('<')
t, _ := p.parseTypeAfterAngle(pkg, n...)
return t
}
// (*parser).Type after reading the "<".
-func (p *parser) parseTypeAfterAngle(pkg *types.Package, n ...interface{}) (t types.Type, n1 int) {
+func (p *parser) parseTypeAfterAngle(pkg *types.Package, n ...any) (t types.Type, n1 int) {
p.expectKeyword("type")
n1 = 0
@@ -985,7 +985,7 @@ func (p *parser) parseTypeAfterAngle(pkg *types.Package, n ...interface{}) (t ty
// parseTypeExtended is identical to parseType, but if the type in
// question is a saved type, returns the index as well as the type
// pointer (index returned is zero if we parsed a builtin).
-func (p *parser) parseTypeExtended(pkg *types.Package, n ...interface{}) (t types.Type, n1 int) {
+func (p *parser) parseTypeExtended(pkg *types.Package, n ...any) (t types.Type, n1 int) {
p.expect('<')
t, n1 = p.parseTypeAfterAngle(pkg, n...)
return
@@ -1072,7 +1072,7 @@ func (p *parser) parseTypes(pkg *types.Package) {
}
// parseSavedType parses one saved type definition.
-func (p *parser) parseSavedType(pkg *types.Package, i int, nlist []interface{}) {
+func (p *parser) parseSavedType(pkg *types.Package, i int, nlist []any) {
defer func(s *scanner.Scanner, tok rune, lit string) {
p.scanner = s
p.tok = tok
diff --git a/src/go/internal/gcimporter/gcimporter_test.go b/src/go/internal/gcimporter/gcimporter_test.go
index c0f4e3934b..15a7b176bb 100644
--- a/src/go/internal/gcimporter/gcimporter_test.go
+++ b/src/go/internal/gcimporter/gcimporter_test.go
@@ -390,7 +390,7 @@ var importedObjectTests = []struct {
{"go/internal/gcimporter.FindPkg", "func FindPkg(path string, srcDir string) (filename string, id string)"},
// interfaces
- {"context.Context", "type Context interface{Deadline() (deadline time.Time, ok bool); Done() <-chan struct{}; Err() error; Value(key interface{}) interface{}}"},
+ {"context.Context", "type Context interface{Deadline() (deadline time.Time, ok bool); Done() <-chan struct{}; Err() error; Value(key any) any}"},
{"crypto.Decrypter", "type Decrypter interface{Decrypt(rand io.Reader, msg []byte, opts DecrypterOpts) (plaintext []byte, err error); Public() PublicKey}"},
{"encoding.BinaryMarshaler", "type BinaryMarshaler interface{MarshalBinary() (data []byte, err error)}"},
{"io.Reader", "type Reader interface{Read(p []byte) (n int, err error)}"},
diff --git a/src/go/internal/gcimporter/support.go b/src/go/internal/gcimporter/support.go
index 965e5d8838..61d1b46a68 100644
--- a/src/go/internal/gcimporter/support.go
+++ b/src/go/internal/gcimporter/support.go
@@ -13,7 +13,7 @@ import (
"sync"
)
-func errorf(format string, args ...interface{}) {
+func errorf(format string, args ...any) {
panic(fmt.Sprintf(format, args...))
}
diff --git a/src/go/internal/gcimporter/testdata/exports.go b/src/go/internal/gcimporter/testdata/exports.go
index 91598c03e3..3d5a8c9e39 100644
--- a/src/go/internal/gcimporter/testdata/exports.go
+++ b/src/go/internal/gcimporter/testdata/exports.go
@@ -50,7 +50,7 @@ type (
_ *T10
}
T11 map[int]string
- T12 interface{}
+ T12 any
T13 interface {
m1()
m2(int) float32
@@ -65,7 +65,7 @@ type (
T17 func(x int)
T18 func() float32
T19 func() (x float32)
- T20 func(...interface{})
+ T20 func(...any)
T21 struct{ next *T21 }
T22 struct{ link *T23 }
T23 struct{ link *T22 }
@@ -86,6 +86,6 @@ func F1() {}
func F2(x int) {}
func F3() int { return 0 }
func F4() float32 { return 0 }
-func F5(a, b, c int, u, v, w struct{ x, y T1 }, more ...interface{}) (p, q, r chan<- T10)
+func F5(a, b, c int, u, v, w struct{ x, y T1 }, more ...any) (p, q, r chan<- T10)
func (p *T1) M1()
diff --git a/src/go/parser/error_test.go b/src/go/parser/error_test.go
index a45c897da3..bedfc265b5 100644
--- a/src/go/parser/error_test.go
+++ b/src/go/parser/error_test.go
@@ -154,7 +154,7 @@ func compareErrors(t *testing.T, fset *token.FileSet, expected map[token.Pos]str
}
}
-func checkErrors(t *testing.T, filename string, input interface{}, mode Mode, expectErrors bool) {
+func checkErrors(t *testing.T, filename string, input any, mode Mode, expectErrors bool) {
t.Helper()
src, err := readSource(filename, input)
if err != nil {
diff --git a/src/go/parser/interface.go b/src/go/parser/interface.go
index 85486d2f4b..e4f8c281ea 100644
--- a/src/go/parser/interface.go
+++ b/src/go/parser/interface.go
@@ -22,7 +22,7 @@ import (
// otherwise it returns an error. If src == nil, readSource returns
// the result of reading the file specified by filename.
//
-func readSource(filename string, src interface{}) ([]byte, error) {
+func readSource(filename string, src any) ([]byte, error) {
if src != nil {
switch s := src.(type) {
case string:
@@ -82,7 +82,7 @@ const (
// representing the fragments of erroneous source code). Multiple errors
// are returned via a scanner.ErrorList which is sorted by source position.
//
-func ParseFile(fset *token.FileSet, filename string, src interface{}, mode Mode) (f *ast.File, err error) {
+func ParseFile(fset *token.FileSet, filename string, src any, mode Mode) (f *ast.File, err error) {
if fset == nil {
panic("parser.ParseFile: no token.FileSet provided (fset == nil)")
}
@@ -188,7 +188,7 @@ func ParseDir(fset *token.FileSet, path string, filter func(fs.FileInfo) bool, m
// representing the fragments of erroneous source code). Multiple errors
// are returned via a scanner.ErrorList which is sorted by source position.
//
-func ParseExprFrom(fset *token.FileSet, filename string, src interface{}, mode Mode) (expr ast.Expr, err error) {
+func ParseExprFrom(fset *token.FileSet, filename string, src any, mode Mode) (expr ast.Expr, err error) {
if fset == nil {
panic("parser.ParseExprFrom: no token.FileSet provided (fset == nil)")
}
diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go
index 7c1a8be2fa..e456e2930e 100644
--- a/src/go/parser/parser.go
+++ b/src/go/parser/parser.go
@@ -82,7 +82,7 @@ func (p *parser) allowTypeSets() bool { return p.mode&typeparams.DisallowTypeSet
// ----------------------------------------------------------------------------
// Parsing support
-func (p *parser) printTrace(a ...interface{}) {
+func (p *parser) printTrace(a ...any) {
const dots = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
const n = len(dots)
pos := p.file.Position(p.pos)
diff --git a/src/go/parser/resolver.go b/src/go/parser/resolver.go
index 54732a7fd6..910ca0689c 100644
--- a/src/go/parser/resolver.go
+++ b/src/go/parser/resolver.go
@@ -67,11 +67,11 @@ type resolver struct {
targetStack [][]*ast.Ident // stack of unresolved labels
}
-func (r *resolver) dump(format string, args ...interface{}) {
+func (r *resolver) dump(format string, args ...any) {
fmt.Println(">>> " + r.sprintf(format, args...))
}
-func (r *resolver) sprintf(format string, args ...interface{}) string {
+func (r *resolver) sprintf(format string, args ...any) string {
for i, arg := range args {
switch arg := arg.(type) {
case token.Pos:
@@ -115,7 +115,7 @@ func (r *resolver) closeLabelScope() {
r.labelScope = r.labelScope.Outer
}
-func (r *resolver) declare(decl, data interface{}, scope *ast.Scope, kind ast.ObjKind, idents ...*ast.Ident) {
+func (r *resolver) declare(decl, data any, scope *ast.Scope, kind ast.ObjKind, idents ...*ast.Ident) {
for _, ident := range idents {
assert(ident.Obj == nil, "identifier already declared or resolved")
obj := ast.NewObj(kind, ident.Name)
diff --git a/src/go/printer/printer.go b/src/go/printer/printer.go
index 2f41e7bf72..e4679b0021 100644
--- a/src/go/printer/printer.go
+++ b/src/go/printer/printer.go
@@ -104,7 +104,7 @@ func (p *printer) init(cfg *Config, fset *token.FileSet, nodeSizes map[ast.Node]
p.cachedPos = -1
}
-func (p *printer) internalError(msg ...interface{}) {
+func (p *printer) internalError(msg ...any) {
if debug {
fmt.Print(p.pos.String() + ": ")
fmt.Println(msg...)
@@ -878,7 +878,7 @@ func mayCombine(prev token.Token, next byte) (b bool) {
// space for best comment placement. Then, any leftover whitespace is
// printed, followed by the actual token.
//
-func (p *printer) print(args ...interface{}) {
+func (p *printer) print(args ...any) {
for _, arg := range args {
// information about the current arg
var data string
@@ -1075,7 +1075,7 @@ func getLastComment(n ast.Node) *ast.CommentGroup {
return nil
}
-func (p *printer) printNode(node interface{}) error {
+func (p *printer) printNode(node any) error {
// unpack *CommentedNode, if any
var comments []*ast.CommentGroup
if cnode, ok := node.(*CommentedNode); ok {
@@ -1309,7 +1309,7 @@ type Config struct {
}
// fprint implements Fprint and takes a nodesSizes map for setting up the printer state.
-func (cfg *Config) fprint(output io.Writer, fset *token.FileSet, node interface{}, nodeSizes map[ast.Node]int) (err error) {
+func (cfg *Config) fprint(output io.Writer, fset *token.FileSet, node any, nodeSizes map[ast.Node]int) (err error) {
// print node
var p printer
p.init(cfg, fset, nodeSizes)
@@ -1365,7 +1365,7 @@ func (cfg *Config) fprint(output io.Writer, fset *token.FileSet, node interface{
// It may be provided as argument to any of the Fprint functions.
//
type CommentedNode struct {
- Node interface{} // *ast.File, or ast.Expr, ast.Decl, ast.Spec, or ast.Stmt
+ Node any // *ast.File, or ast.Expr, ast.Decl, ast.Spec, or ast.Stmt
Comments []*ast.CommentGroup
}
@@ -1374,7 +1374,7 @@ type CommentedNode struct {
// The node type must be *ast.File, *CommentedNode, []ast.Decl, []ast.Stmt,
// or assignment-compatible to ast.Expr, ast.Decl, ast.Spec, or ast.Stmt.
//
-func (cfg *Config) Fprint(output io.Writer, fset *token.FileSet, node interface{}) error {
+func (cfg *Config) Fprint(output io.Writer, fset *token.FileSet, node any) error {
return cfg.fprint(output, fset, node, make(map[ast.Node]int))
}
@@ -1383,6 +1383,6 @@ func (cfg *Config) Fprint(output io.Writer, fset *token.FileSet, node interface{
// Note that gofmt uses tabs for indentation but spaces for alignment;
// use format.Node (package go/format) for output that matches gofmt.
//
-func Fprint(output io.Writer, fset *token.FileSet, node interface{}) error {
+func Fprint(output io.Writer, fset *token.FileSet, node any) error {
return (&Config{Tabwidth: 8}).Fprint(output, fset, node)
}
diff --git a/src/go/printer/testdata/parser.go b/src/go/printer/testdata/parser.go
index fc2812adee..7e8379739c 100644
--- a/src/go/printer/testdata/parser.go
+++ b/src/go/printer/testdata/parser.go
@@ -122,7 +122,7 @@ func (p *parser) closeLabelScope() {
p.labelScope = p.labelScope.Outer
}
-func (p *parser) declare(decl interface{}, scope *ast.Scope, kind ast.ObjKind, idents ...*ast.Ident) {
+func (p *parser) declare(decl any, scope *ast.Scope, kind ast.ObjKind, idents ...*ast.Ident) {
for _, ident := range idents {
assert(ident.Obj == nil, "identifier already declared or resolved")
if ident.Name != "_" {
@@ -200,7 +200,7 @@ func (p *parser) resolve(x ast.Expr) {
// ----------------------------------------------------------------------------
// Parsing support
-func (p *parser) printTrace(a ...interface{}) {
+func (p *parser) printTrace(a ...any) {
const dots = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " +
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
const n = uint(len(dots))
diff --git a/src/go/scanner/scanner.go b/src/go/scanner/scanner.go
index ca4b5264cf..23d8db9d1c 100644
--- a/src/go/scanner/scanner.go
+++ b/src/go/scanner/scanner.go
@@ -155,7 +155,7 @@ func (s *Scanner) error(offs int, msg string) {
s.ErrorCount++
}
-func (s *Scanner) errorf(offs int, format string, args ...interface{}) {
+func (s *Scanner) errorf(offs int, format string, args ...any) {
s.error(offs, fmt.Sprintf(format, args...))
}
diff --git a/src/go/token/serialize.go b/src/go/token/serialize.go
index d0ea34517a..ffb69908b9 100644
--- a/src/go/token/serialize.go
+++ b/src/go/token/serialize.go
@@ -19,7 +19,7 @@ type serializedFileSet struct {
}
// Read calls decode to deserialize a file set into s; s must not be nil.
-func (s *FileSet) Read(decode func(interface{}) error) error {
+func (s *FileSet) Read(decode func(any) error) error {
var ss serializedFileSet
if err := decode(&ss); err != nil {
return err
@@ -47,7 +47,7 @@ func (s *FileSet) Read(decode func(interface{}) error) error {
}
// Write calls encode to serialize the file set s.
-func (s *FileSet) Write(encode func(interface{}) error) error {
+func (s *FileSet) Write(encode func(any) error) error {
var ss serializedFileSet
s.mutex.Lock()
diff --git a/src/go/token/serialize_test.go b/src/go/token/serialize_test.go
index 4e925adb6f..4aa0b0da26 100644
--- a/src/go/token/serialize_test.go
+++ b/src/go/token/serialize_test.go
@@ -70,7 +70,7 @@ func equal(p, q *FileSet) error {
func checkSerialize(t *testing.T, p *FileSet) {
var buf bytes.Buffer
- encode := func(x interface{}) error {
+ encode := func(x any) error {
return gob.NewEncoder(&buf).Encode(x)
}
if err := p.Write(encode); err != nil {
@@ -78,7 +78,7 @@ func checkSerialize(t *testing.T, p *FileSet) {
return
}
q := NewFileSet()
- decode := func(x interface{}) error {
+ decode := func(x any) error {
return gob.NewDecoder(&buf).Decode(x)
}
if err := q.Read(decode); err != nil {
diff --git a/src/go/types/check.go b/src/go/types/check.go
index d967c0bd25..2dd38e2e1e 100644
--- a/src/go/types/check.go
+++ b/src/go/types/check.go
@@ -90,7 +90,7 @@ type action struct {
// If debug is set, describef sets a printf-formatted description for action a.
// Otherwise, it is a no-op.
-func (a *action) describef(pos positioner, format string, args ...interface{}) {
+func (a *action) describef(pos positioner, format string, args ...any) {
if debug {
a.desc = &actionDesc{pos, format, args}
}
@@ -101,7 +101,7 @@ func (a *action) describef(pos positioner, format string, args ...interface{}) {
type actionDesc struct {
pos positioner
format string
- args []interface{}
+ args []any
}
// A Checker maintains the state of the type checker.
diff --git a/src/go/types/conversions.go b/src/go/types/conversions.go
index fb3771635d..a5b359e539 100644
--- a/src/go/types/conversions.go
+++ b/src/go/types/conversions.go
@@ -203,7 +203,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
return false
}
- errorf := func(format string, args ...interface{}) {
+ errorf := func(format string, args ...any) {
if check != nil && cause != nil {
msg := check.sprintf(format, args...)
if *cause != "" {
diff --git a/src/go/types/errors.go b/src/go/types/errors.go
index 92002add13..81c62a82f0 100644
--- a/src/go/types/errors.go
+++ b/src/go/types/errors.go
@@ -62,11 +62,11 @@ func (check *Checker) markImports(pkg *Package) {
}
}
-func (check *Checker) sprintf(format string, args ...interface{}) string {
+func (check *Checker) sprintf(format string, args ...any) string {
return sprintf(check.fset, check.qualifier, false, format, args...)
}
-func sprintf(fset *token.FileSet, qf Qualifier, debug bool, format string, args ...interface{}) string {
+func sprintf(fset *token.FileSet, qf Qualifier, debug bool, format string, args ...any) string {
for i, arg := range args {
switch a := arg.(type) {
case nil:
@@ -91,7 +91,7 @@ func sprintf(fset *token.FileSet, qf Qualifier, debug bool, format string, args
return fmt.Sprintf(format, args...)
}
-func (check *Checker) trace(pos token.Pos, format string, args ...interface{}) {
+func (check *Checker) trace(pos token.Pos, format string, args ...any) {
fmt.Printf("%s:\t%s%s\n",
check.fset.Position(pos),
strings.Repeat(". ", check.indent),
@@ -100,7 +100,7 @@ func (check *Checker) trace(pos token.Pos, format string, args ...interface{}) {
}
// dump is only needed for debugging
-func (check *Checker) dump(format string, args ...interface{}) {
+func (check *Checker) dump(format string, args ...any) {
fmt.Println(sprintf(check.fset, check.qualifier, true, format, args...))
}
@@ -170,7 +170,7 @@ func (check *Checker) newError(at positioner, code errorCode, soft bool, msg str
}
// newErrorf creates a new Error, but does not handle it.
-func (check *Checker) newErrorf(at positioner, code errorCode, soft bool, format string, args ...interface{}) error {
+func (check *Checker) newErrorf(at positioner, code errorCode, soft bool, format string, args ...any) error {
msg := check.sprintf(format, args...)
return check.newError(at, code, soft, msg)
}
@@ -179,23 +179,23 @@ func (check *Checker) error(at positioner, code errorCode, msg string) {
check.err(check.newError(at, code, false, msg))
}
-func (check *Checker) errorf(at positioner, code errorCode, format string, args ...interface{}) {
+func (check *Checker) errorf(at positioner, code errorCode, format string, args ...any) {
check.error(at, code, check.sprintf(format, args...))
}
-func (check *Checker) softErrorf(at positioner, code errorCode, format string, args ...interface{}) {
+func (check *Checker) softErrorf(at positioner, code errorCode, format string, args ...any) {
check.err(check.newErrorf(at, code, true, format, args...))
}
-func (check *Checker) invalidAST(at positioner, format string, args ...interface{}) {
+func (check *Checker) invalidAST(at positioner, format string, args ...any) {
check.errorf(at, 0, "invalid AST: "+format, args...)
}
-func (check *Checker) invalidArg(at positioner, code errorCode, format string, args ...interface{}) {
+func (check *Checker) invalidArg(at positioner, code errorCode, format string, args ...any) {
check.errorf(at, code, "invalid argument: "+format, args...)
}
-func (check *Checker) invalidOp(at positioner, code errorCode, format string, args ...interface{}) {
+func (check *Checker) invalidOp(at positioner, code errorCode, format string, args ...any) {
check.errorf(at, code, "invalid operation: "+format, args...)
}
diff --git a/src/go/types/eval_test.go b/src/go/types/eval_test.go
index 345bd14305..b0745c16d9 100644
--- a/src/go/types/eval_test.go
+++ b/src/go/types/eval_test.go
@@ -111,7 +111,7 @@ func TestEvalPos(t *testing.T) {
x = a + len(s)
return float64(x)
/* true => true, untyped bool */
- /* fmt.Println => , func(a ...interface{}) (n int, err error) */
+ /* fmt.Println => , func(a ...any) (n int, err error) */
/* c => 3, untyped float */
/* T => , p.T */
/* a => , int */
@@ -218,7 +218,7 @@ type T []int
type S struct{ X int }
func f(a int, s string) S {
- /* fmt.Println => func fmt.Println(a ...interface{}) (n int, err error) */
+ /* fmt.Println => func fmt.Println(a ...any) (n int, err error) */
/* fmt.Stringer.String => func (fmt.Stringer).String() string */
fmt.Println("calling f")
diff --git a/src/go/types/expr.go b/src/go/types/expr.go
index dd18abaf13..452e9ab598 100644
--- a/src/go/types/expr.go
+++ b/src/go/types/expr.go
@@ -1354,7 +1354,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
check.error(e, _InvalidTypeCycle, "illegal cycle in type declaration")
goto Error
}
- visited := make(map[interface{}][]Type, len(e.Elts))
+ visited := make(map[any][]Type, len(e.Elts))
for _, e := range e.Elts {
kv, _ := e.(*ast.KeyValueExpr)
if kv == nil {
@@ -1542,7 +1542,7 @@ Error:
return statement // avoid follow-up errors
}
-func keyVal(x constant.Value) interface{} {
+func keyVal(x constant.Value) any {
switch x.Kind() {
case constant.Bool:
return constant.BoolVal(x)
diff --git a/src/go/types/gotype.go b/src/go/types/gotype.go
index 1126b73810..5d27bb7a07 100644
--- a/src/go/types/gotype.go
+++ b/src/go/types/gotype.go
@@ -179,7 +179,7 @@ func report(err error) {
}
// parse may be called concurrently
-func parse(filename string, src interface{}) (*ast.File, error) {
+func parse(filename string, src any) (*ast.File, error) {
if *verbose {
fmt.Println(filename)
}
diff --git a/src/go/types/hilbert_test.go b/src/go/types/hilbert_test.go
index 77954d2f8b..7d0f58ea40 100644
--- a/src/go/types/hilbert_test.go
+++ b/src/go/types/hilbert_test.go
@@ -84,7 +84,7 @@ type gen struct {
bytes.Buffer
}
-func (g *gen) p(format string, args ...interface{}) {
+func (g *gen) p(format string, args ...any) {
fmt.Fprintf(&g.Buffer, format, args...)
}
diff --git a/src/go/types/initorder.go b/src/go/types/initorder.go
index 27595ae233..1118b58f7b 100644
--- a/src/go/types/initorder.go
+++ b/src/go/types/initorder.go
@@ -304,11 +304,11 @@ func (a nodeQueue) Less(i, j int) bool {
return x.ndeps < y.ndeps || x.ndeps == y.ndeps && x.obj.order() < y.obj.order()
}
-func (a *nodeQueue) Push(x interface{}) {
+func (a *nodeQueue) Push(x any) {
panic("unreachable")
}
-func (a *nodeQueue) Pop() interface{} {
+func (a *nodeQueue) Pop() any {
n := len(*a)
x := (*a)[n-1]
x.index = -1 // for safety
diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go
index e91d08cc5e..e8748975c9 100644
--- a/src/go/types/instantiate.go
+++ b/src/go/types/instantiate.go
@@ -164,7 +164,7 @@ func (check *Checker) implements(V, T Type, qf Qualifier) error {
return nil
}
- errorf := func(format string, args ...interface{}) error {
+ errorf := func(format string, args ...any) error {
return errors.New(sprintf(nil, qf, false, format, args...))
}
diff --git a/src/go/types/operand.go b/src/go/types/operand.go
index c35b1650be..06ecbf1410 100644
--- a/src/go/types/operand.go
+++ b/src/go/types/operand.go
@@ -337,7 +337,7 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er
return false, _IncompatibleAssign
}
- errorf := func(format string, args ...interface{}) {
+ errorf := func(format string, args ...any) {
if check != nil && reason != nil {
msg := check.sprintf(format, args...)
if *reason != "" {
diff --git a/src/go/types/sizeof_test.go b/src/go/types/sizeof_test.go
index 5b7ee8bb78..69571d1159 100644
--- a/src/go/types/sizeof_test.go
+++ b/src/go/types/sizeof_test.go
@@ -14,9 +14,9 @@ func TestSizeof(t *testing.T) {
const _64bit = ^uint(0)>>32 != 0
var tests = []struct {
- val interface{} // type as a value
- _32bit uintptr // size on 32bit platforms
- _64bit uintptr // size on 64bit platforms
+ val any // type as a value
+ _32bit uintptr // size on 32bit platforms
+ _64bit uintptr // size on 64bit platforms
}{
// Types
{Basic{}, 16, 32},
diff --git a/src/go/types/stdlib_test.go b/src/go/types/stdlib_test.go
index 687b80540a..5e5e09562a 100644
--- a/src/go/types/stdlib_test.go
+++ b/src/go/types/stdlib_test.go
@@ -296,7 +296,7 @@ func pkgFilenames(dir string) ([]string, error) {
return filenames, nil
}
-func walkPkgDirs(dir string, pkgh func(dir string, filenames []string), errh func(args ...interface{})) time.Duration {
+func walkPkgDirs(dir string, pkgh func(dir string, filenames []string), errh func(args ...any)) time.Duration {
w := walker{time.Now(), 10 * time.Millisecond, pkgh, errh}
w.walk(dir)
return time.Since(w.start)
@@ -306,7 +306,7 @@ type walker struct {
start time.Time
dmax time.Duration
pkgh func(dir string, filenames []string)
- errh func(args ...interface{})
+ errh func(args ...any)
}
func (w *walker) walk(dir string) {
diff --git a/src/go/types/stmt.go b/src/go/types/stmt.go
index 06c9d3175d..8621d2800a 100644
--- a/src/go/types/stmt.go
+++ b/src/go/types/stmt.go
@@ -193,7 +193,7 @@ func (check *Checker) suspendedCall(keyword string, call *ast.CallExpr) {
}
// goVal returns the Go value for val, or nil.
-func goVal(val constant.Value) interface{} {
+func goVal(val constant.Value) any {
// val should exist, but be conservative and check
if val == nil {
return nil
@@ -227,7 +227,7 @@ func goVal(val constant.Value) interface{} {
// types we need to also check the value's types (e.g., byte(1) vs myByte(1))
// when the switch expression is of interface type.
type (
- valueMap map[interface{}][]valueType // underlying Go value -> valueType
+ valueMap map[any][]valueType // underlying Go value -> valueType
valueType struct {
pos token.Pos
typ Type
diff --git a/src/go/types/subst.go b/src/go/types/subst.go
index 04eb3a6215..169540365b 100644
--- a/src/go/types/subst.go
+++ b/src/go/types/subst.go
@@ -156,13 +156,13 @@ func (subst *subster) typ(typ Type) Type {
case *Named:
// dump is for debugging
- dump := func(string, ...interface{}) {}
+ dump := func(string, ...any) {}
if subst.check != nil && trace {
subst.check.indent++
defer func() {
subst.check.indent--
}()
- dump = func(format string, args ...interface{}) {
+ dump = func(format string, args ...any) {
subst.check.trace(subst.pos, format, args...)
}
}