diff options
author | Matthias Bertschy <matthias.bertschy@gmail.com> | 2019-07-04 08:33:00 +0200 |
---|---|---|
committer | Matthias Bertschy <matthias.bertschy@gmail.com> | 2019-07-12 08:09:48 +0200 |
commit | 239d7c6fdf344fe7051328056b7578657c7b6950 (patch) | |
tree | eb586f1fa583c86b7834718e2fa35974b9f0df7e /tools/go_generics/globals | |
parent | 67f2cefce02816307805699c3462d6fd7ce61b69 (diff) |
go_generics: treat the Sel part of an ast.SelectorExpr
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() |