diff options
Diffstat (limited to 'src/pkg/go/ast/walk.go')
-rw-r--r-- | src/pkg/go/ast/walk.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/pkg/go/ast/walk.go b/src/pkg/go/ast/walk.go index 104596623..33a2d3294 100644 --- a/src/pkg/go/ast/walk.go +++ b/src/pkg/go/ast/walk.go @@ -41,7 +41,7 @@ func walkBlockStmt(v Visitor, b *BlockStmt) { // followed by a call of w.Visit(nil). // // Walk may be called with any of the named ast node types. It also -// accepts arguments of type []*Field, []*Ident, []Expr and []Stmt; +// accepts arguments of type []*Field, []*Ident, []Expr, []Stmt and []Decl; // the respective children are the slice elements. // func Walk(v Visitor, node interface{}) { @@ -291,9 +291,7 @@ func Walk(v Visitor, node interface{}) { case *File: walkCommentGroup(v, n.Doc) walkIdent(v, n.Name) - for _, d := range n.Decls { - Walk(v, d) - } + Walk(v, n.Decls) walkCommentGroup(v, n.Comments) case *Package: @@ -321,6 +319,11 @@ func Walk(v Visitor, node interface{}) { Walk(v, x) } + case []Decl: + for _, x := range n { + Walk(v, x) + } + default: fmt.Printf("ast.Walk: unexpected type %T", n) panic() |