]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types: consistently use _ prefix for unexported names that are exported in types2
authorRobert Griesemer <gri@golang.org>
Thu, 12 Jan 2023 18:15:08 +0000 (10:15 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 17 Jan 2023 19:56:36 +0000 (19:56 +0000)
Change-Id: Ic9b24b4b3a6336782023c7db40cc937f2dc743df
Reviewed-on: https://go-review.googlesource.com/c/go/+/461606
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
14 files changed:
src/go/types/api.go
src/go/types/call.go
src/go/types/check.go
src/go/types/check_test.go
src/go/types/decl.go
src/go/types/errors.go
src/go/types/expr.go
src/go/types/generator.go
src/go/types/named.go
src/go/types/sizes.go
src/go/types/stmt.go
src/go/types/subst.go
src/go/types/typeset.go
src/go/types/typexpr.go

index d9d561c25dc73e0a5591a8b61a57c609a0f6ef56..11e5dfbd0431f9d65d54e22ff897fd6575c8e09c 100644 (file)
@@ -143,8 +143,8 @@ type Config struct {
        // It is an error to set both FakeImportC and go115UsesCgo.
        go115UsesCgo bool
 
-       // If trace is set, a debug trace is printed to stdout.
-       trace bool
+       // If _Trace is set, a debug trace is printed to stdout.
+       _Trace bool
 
        // If Error != nil, it is called with each error found
        // during type checking; err has dynamic type Error.
index 53c5a64fb0510534c9167214297de3873b52605a..e44c025eac89f8f9f9f3e338f2aa5d1fe7c7895c 100644 (file)
@@ -65,7 +65,7 @@ func (check *Checker) instantiateSignature(pos token.Pos, typ *Signature, targs
        assert(check != nil)
        assert(len(targs) == typ.TypeParams().Len())
 
-       if check.conf.trace {
+       if check.conf._Trace {
                check.trace(pos, "-- instantiating signature %s with %s", typ, targs)
                check.indent++
                defer func() {
index 60d3e1ac4bcbc2545013f2ded8c6d1c4c23ac19d..b862ba57b8c44703ffa6843868f314c65f322c83 100644 (file)
@@ -313,7 +313,7 @@ func (check *Checker) checkFiles(files []*ast.File) (err error) {
        defer check.handleBailout(&err)
 
        print := func(msg string) {
-               if check.conf.trace {
+               if check.conf._Trace {
                        fmt.Println()
                        fmt.Println(msg)
                }
@@ -377,7 +377,7 @@ func (check *Checker) processDelayed(top int) {
        // this is a sufficiently bounded process.
        for i := top; i < len(check.delayed); i++ {
                a := &check.delayed[i]
-               if check.conf.trace {
+               if check.conf._Trace {
                        if a.desc != nil {
                                check.trace(a.desc.pos.Pos(), "-- "+a.desc.format, a.desc.args...)
                        } else {
@@ -385,7 +385,7 @@ func (check *Checker) processDelayed(top int) {
                        }
                }
                a.f() // may append to check.delayed
-               if check.conf.trace {
+               if check.conf._Trace {
                        fmt.Println()
                }
        }
index 1107f9592aa2e1f58e952cf9ac80c04404ffb77f..3ba26bfb5a6fdbd07e22788aa889778093b0f332 100644 (file)
@@ -166,7 +166,7 @@ func testFiles(t *testing.T, sizes Sizes, filenames []string, srcs [][]byte, man
        }
 
        // typecheck and collect typechecker errors
-       *boolFieldAddr(&conf, "trace") = manual && testing.Verbose()
+       *boolFieldAddr(&conf, "_Trace") = manual && testing.Verbose()
        if imp == nil {
                imp = importer.Default()
        }
index 9d84cf4da642d2ee74e1e9acea9e52963b44952a..2493103b9fdeab741ce2abffcf739d88c378e421 100644 (file)
@@ -54,7 +54,7 @@ func pathString(path []Object) string {
 // objDecl type-checks the declaration of obj in its respective (file) environment.
 // For the meaning of def, see Checker.definedType, in typexpr.go.
 func (check *Checker) objDecl(obj Object, def *Named) {
-       if check.conf.trace && obj.Type() == nil {
+       if check.conf._Trace && obj.Type() == nil {
                if check.indent == 0 {
                        fmt.Println() // empty line between top-level objects for readability
                }
@@ -264,7 +264,7 @@ loop:
                }
        }
 
-       if check.conf.trace {
+       if check.conf._Trace {
                check.trace(obj.Pos(), "## cycle detected: objPath = %s->%s (len = %d)", pathString(cycle), obj.Name(), len(cycle))
                if tparCycle {
                        check.trace(obj.Pos(), "## cycle contains: generic type in a type parameter list")
@@ -707,7 +707,7 @@ func (check *Checker) declareTypeParams(tparams []*TypeParam, names []*ast.Ident
                tparams = append(tparams, tpar)
        }
 
-       if check.conf.trace && len(names) > 0 {
+       if check.conf._Trace && len(names) > 0 {
                check.trace(names[0].Pos(), "type params = %v", tparams[len(tparams)-len(names):])
        }
 
index 95ee51e2cab70b55ab06b14dc341a5c87ae6a2e9..7f1cb2057c7bed422f65fb49fdd4e1f3d3634516 100644 (file)
@@ -266,7 +266,7 @@ func (check *Checker) report(errp *error_) {
                check.firstErr = err
        }
 
-       if check.conf.trace {
+       if check.conf._Trace {
                pos := e.Pos
                msg := e.Msg
                check.trace(pos, "ERROR: %s", msg)
index adf3d21fced6a3b58bc7a4572bc9a0f91c05c72c..bbbc5cc5a6df0518745f823f719f20b50a2f667a 100644 (file)
@@ -1224,7 +1224,7 @@ const (
 // If allowGeneric is set, the operand type may be an uninstantiated
 // parameterized type or function value.
 func (check *Checker) rawExpr(x *operand, e ast.Expr, hint Type, allowGeneric bool) exprKind {
-       if check.conf.trace {
+       if check.conf._Trace {
                check.trace(e.Pos(), "-- expr %s", e)
                check.indent++
                defer func() {
index a053072f6bdab8a3cf7aa6b1b9c6472fc6333cf3..2c6ef66c4acc3589400fd383a7e584b5ce4cf1bb 100644 (file)
@@ -105,7 +105,7 @@ var filemap = map[string]action{
                renameIdent(f, "InsertLazy", "_InsertLazy")
        },
        "selection.go":     nil,
-       "sizes.go":         func(f *ast.File) { renameIdent(f, "IsSyncAtomicAlign64", "isSyncAtomicAlign64") },
+       "sizes.go":         func(f *ast.File) { renameIdent(f, "IsSyncAtomicAlign64", "_IsSyncAtomicAlign64") },
        "slice.go":         nil,
        "subst.go":         func(f *ast.File) { fixTokenPos(f); fixTraceSel(f) },
        "termlist.go":      nil,
@@ -187,9 +187,9 @@ func fixTraceSel(f *ast.File) {
        ast.Inspect(f, func(n ast.Node) bool {
                switch n := n.(type) {
                case *ast.SelectorExpr:
-                       // rewrite x.Trace to x.trace (for Config.Trace)
+                       // rewrite x.Trace to x._Trace (for Config.Trace)
                        if n.Sel.Name == "Trace" {
-                               n.Sel.Name = "trace"
+                               n.Sel.Name = "_Trace"
                                return false
                        }
                }
index f55b55e08a6749c8af8aa17053513bf95ae460e0..586f1af880d660ebd3c1d84814a1d9f569abc2b9 100644 (file)
@@ -583,7 +583,7 @@ func (check *Checker) context() *Context {
 // returning the result. Returns Typ[Invalid] if there was an error.
 func (n *Named) expandUnderlying() Type {
        check := n.check
-       if check != nil && check.conf.trace {
+       if check != nil && check.conf._Trace {
                check.trace(n.obj.pos, "-- Named.expandUnderlying %s", n)
                check.indent++
                defer func() {
index 235718481ca45c30f485cd1f4d5587a6a7190511..fb7a16699a8744c9601f81d2fd298af517901c21 100644 (file)
@@ -55,7 +55,7 @@ func (s *StdSizes) Alignof(T Type) int64 {
                // is the same as unsafe.Alignof(x[0]), but at least 1."
                return s.Alignof(t.elem)
        case *Struct:
-               if len(t.fields) == 0 && isSyncAtomicAlign64(T) {
+               if len(t.fields) == 0 && _IsSyncAtomicAlign64(T) {
                        // Special case: sync/atomic.align64 is an
                        // empty struct we recognize as a signal that
                        // the struct it contains must be
@@ -106,7 +106,7 @@ func (s *StdSizes) Alignof(T Type) int64 {
        return a
 }
 
-func isSyncAtomicAlign64(T Type) bool {
+func _IsSyncAtomicAlign64(T Type) bool {
        named, ok := T.(*Named)
        if !ok {
                return false
index 5c08a74c325472df8d06e9c866e78b0a980b30fe..2a8cf6757fa552901f9db08fba067c919ddad9d9 100644 (file)
@@ -19,7 +19,7 @@ func (check *Checker) funcBody(decl *declInfo, name string, sig *Signature, body
                panic("function body not ignored")
        }
 
-       if check.conf.trace {
+       if check.conf._Trace {
                check.trace(body.Pos(), "-- %s: %s", name, sig)
        }
 
index 9f0eb975b01e6966fa5967838c54575d79479049..3be5c02be2e084f04e7fbdbadbf4c0ab8b00b24d 100644 (file)
@@ -206,7 +206,7 @@ func (subst *subster) typ(typ Type) Type {
        case *Named:
                // dump is for debugging
                dump := func(string, ...interface{}) {}
-               if subst.check != nil && subst.check.conf.trace {
+               if subst.check != nil && subst.check.conf._Trace {
                        subst.check.indent++
                        defer func() {
                                subst.check.indent--
index 64b9734dcdb2017a92aeb95e1f3a0e5a24f92b87..f86e73849d5de55fd74ffe0c451e8a3609b876a2 100644 (file)
@@ -170,7 +170,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T
                return &topTypeSet
        }
 
-       if check != nil && check.conf.trace {
+       if check != nil && check.conf._Trace {
                // Types don't generally have position information.
                // If we don't have a valid pos provided, try to use
                // one close enough.
index 6a92dcb9b73caa8d665ab534e3ade556de28e01f..57ac3b6d48243f3c190b06dfbfb9af8cc289e4bd 100644 (file)
@@ -214,7 +214,7 @@ func goTypeName(typ Type) string {
 // typInternal drives type checking of types.
 // Must only be called by definedType or genericType.
 func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) {
-       if check.conf.trace {
+       if check.conf._Trace {
                check.trace(e0.Pos(), "-- type %s", e0)
                check.indent++
                defer func() {
@@ -395,7 +395,7 @@ func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) {
 }
 
 func (check *Checker) instantiatedType(ix *typeparams.IndexExpr, def *Named) (res Type) {
-       if check.conf.trace {
+       if check.conf._Trace {
                check.trace(ix.Pos(), "-- instantiating type %s with %s", ix.X, ix.Indices)
                check.indent++
                defer func() {