diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-07-17 15:32:59 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-07-17 15:32:59 -0700 |
commit | 8e2ea9c1e0fe9b1b4a346ce0a6ceb94fb822f241 (patch) | |
tree | cef8a02142285b34a8883af147b912a596acccc3 /tools/go_generics/globals | |
parent | 8e3e021aca89427381af75a47f19b1fe78bf132e (diff) | |
parent | 239d7c6fdf344fe7051328056b7578657c7b6950 (diff) |
Merge pull request #504 from matthyx:master
PiperOrigin-RevId: 258654826
Diffstat (limited to 'tools/go_generics/globals')
-rw-r--r-- | tools/go_generics/globals/globals_visitor.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/go_generics/globals/globals_visitor.go b/tools/go_generics/globals/globals_visitor.go index 3f948637b..883f21ebe 100644 --- a/tools/go_generics/globals/globals_visitor.go +++ b/tools/go_generics/globals/globals_visitor.go @@ -47,6 +47,11 @@ type globalsVisitor struct { // scope is the current scope as nodes are visited. scope *scope + + // processAnon indicates whether we should process anonymous struct fields. + // It does not perform strict checking on parameter types that share the same name + // as the global type and therefore will rename them as well. + processAnon bool } // unexpected is called when an unexpected node appears in the AST. It dumps @@ -307,6 +312,9 @@ func (v *globalsVisitor) visitExpr(ge ast.Expr) { case *ast.SelectorExpr: v.visitExpr(e.X) + if v.processAnon { + v.visitExpr(e.Sel) + } case *ast.SliceExpr: v.visitExpr(e.X) @@ -577,11 +585,12 @@ func (v *globalsVisitor) visit() { // // The function f() is allowed to modify the identifier, for example, to rename // uses of global references. -func Visit(fset *token.FileSet, file *ast.File, f func(*ast.Ident, SymKind)) { +func Visit(fset *token.FileSet, file *ast.File, f func(*ast.Ident, SymKind), processAnon bool) { v := globalsVisitor{ - fset: fset, - file: file, - f: f, + fset: fset, + file: file, + f: f, + processAnon: processAnon, } v.visit() |