@@ -199,7 +199,7 @@ type applyVisitor interface {
199
199
200
200
// Helper functions for common node lists. They may be empty.
201
201
202
- func applyExprList (v applyVisitor , parent Cursor , ptr interface {}, list []ast.Expr ) {
202
+ func applyExprList (v applyVisitor , parent Cursor , list []ast.Expr ) {
203
203
c := newCursor (parent , nil , nil )
204
204
for i , x := range list {
205
205
c .index = i
@@ -286,14 +286,12 @@ func applyDeclList(v applyVisitor, parent Cursor, list []ast.Decl) []ast.Decl {
286
286
return c .decls
287
287
}
288
288
289
- func apply (v applyVisitor , parent Cursor , nodePtr interface {}) {
290
- res := reflect .Indirect (reflect .ValueOf (nodePtr ))
291
- n := res .Interface ()
292
- node := n .(ast.Node )
289
+ func apply [N ast.Node ](v applyVisitor , parent Cursor , nodePtr * N ) {
290
+ node := * nodePtr
293
291
c := newCursor (parent , node , nodePtr )
294
292
applyCursor (v , c )
295
- if node != c .node {
296
- res . Set ( reflect . ValueOf ( c .node ) )
293
+ if ast . Node ( node ) != c .node {
294
+ * nodePtr = c .node .( N )
297
295
}
298
296
}
299
297
@@ -349,10 +347,10 @@ func applyCursor(v applyVisitor, c Cursor) {
349
347
// nothing to do
350
348
351
349
case * ast.Interpolation :
352
- applyExprList (v , c , & n , n .Elts )
350
+ applyExprList (v , c , n .Elts )
353
351
354
352
case * ast.ListLit :
355
- applyExprList (v , c , & n , n .Elts )
353
+ applyExprList (v , c , n .Elts )
356
354
357
355
case * ast.Ellipsis :
358
356
if n .Type != nil {
@@ -381,7 +379,7 @@ func applyCursor(v applyVisitor, c Cursor) {
381
379
382
380
case * ast.CallExpr :
383
381
apply (v , c , & n .Fun )
384
- applyExprList (v , c , & n , n .Args )
382
+ applyExprList (v , c , n .Args )
385
383
386
384
case * ast.UnaryExpr :
387
385
apply (v , c , & n .X )
0 commit comments