diff options
Diffstat (limited to 'go/ast/astutil/rewrite_test.go')
-rw-r--r-- | go/ast/astutil/rewrite_test.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/go/ast/astutil/rewrite_test.go b/go/ast/astutil/rewrite_test.go index 9d23170a5..4ef6fe99d 100644 --- a/go/ast/astutil/rewrite_test.go +++ b/go/ast/astutil/rewrite_test.go @@ -202,20 +202,30 @@ func init() { type T[P1, P2 any] int type R T[int, string] + +func F[Q1 any](q Q1) {} `, + // TODO: note how the rewrite adds a trailing comma in "func F". + // Is that a bug in the test, or in astutil.Apply? want: `package p -type S[P1, P2 any] int32 +type S[R1, P2 any] int32 type R S[int32, string] + +func F[X1 any](q X1,) {} `, post: func(c *astutil.Cursor) bool { if ident, ok := c.Node().(*ast.Ident); ok { - if ident.Name == "int" { + switch ident.Name { + case "int": c.Replace(ast.NewIdent("int32")) - } - if ident.Name == "T" { + case "T": c.Replace(ast.NewIdent("S")) + case "P1": + c.Replace(ast.NewIdent("R1")) + case "Q1": + c.Replace(ast.NewIdent("X1")) } } return true |