golang.org/x/tools/gopls@v0.15.3/internal/test/marker/testdata/rename/generics_basic.txt (about) 1 This test exercise basic renaming of generic code. 2 3 -- embedded.go -- 4 package a 5 6 type foo[P any] int //@rename("foo", "bar", fooTobar) 7 8 var x struct{ foo[int] } 9 10 var _ = x.foo 11 12 -- @fooTobar/embedded.go -- 13 @@ -3 +3 @@ 14 -type foo[P any] int //@rename("foo", "bar", fooTobar) 15 +type bar[P any] int //@rename("foo", "bar", fooTobar) 16 @@ -5 +5 @@ 17 -var x struct{ foo[int] } 18 +var x struct{ bar[int] } 19 @@ -7 +7 @@ 20 -var _ = x.foo 21 +var _ = x.bar 22 -- generics.go -- 23 package a 24 25 type G[P any] struct { 26 F int 27 } 28 29 func (G[_]) M() {} 30 31 func F[P any](P) { 32 var p P //@rename("P", "Q", PToQ) 33 _ = p 34 } 35 36 func _() { 37 var x G[int] //@rename("G", "H", GToH) 38 _ = x.F //@rename("F", "K", FToK) 39 x.M() //@rename("M", "N", MToN) 40 41 var y G[string] 42 _ = y.F 43 y.M() 44 } 45 46 -- @FToK/generics.go -- 47 @@ -4 +4 @@ 48 - F int 49 + K int 50 @@ -16 +16 @@ 51 - _ = x.F //@rename("F", "K", FToK) 52 + _ = x.K //@rename("F", "K", FToK) 53 @@ -20 +20 @@ 54 - _ = y.F 55 + _ = y.K 56 -- @GToH/generics.go -- 57 @@ -3 +3 @@ 58 -type G[P any] struct { 59 +type H[P any] struct { 60 @@ -7 +7 @@ 61 -func (G[_]) M() {} 62 +func (H[_]) M() {} 63 @@ -15 +15 @@ 64 - var x G[int] //@rename("G", "H", GToH) 65 + var x H[int] //@rename("G", "H", GToH) 66 @@ -19 +19 @@ 67 - var y G[string] 68 + var y H[string] 69 -- @MToN/generics.go -- 70 @@ -7 +7 @@ 71 -func (G[_]) M() {} 72 +func (G[_]) N() {} 73 @@ -17 +17 @@ 74 - x.M() //@rename("M", "N", MToN) 75 + x.N() //@rename("M", "N", MToN) 76 @@ -21 +21 @@ 77 - y.M() 78 + y.N() 79 -- @PToQ/generics.go -- 80 @@ -9,2 +9,2 @@ 81 -func F[P any](P) { 82 - var p P //@rename("P", "Q", PToQ) 83 +func F[Q any](Q) { 84 + var p Q //@rename("P", "Q", PToQ) 85 -- unions.go -- 86 package a 87 88 type T string //@rename("T", "R", TToR) 89 90 type C interface { 91 T | ~int //@rename("T", "S", TToS) 92 } 93 94 -- @TToR/unions.go -- 95 @@ -3 +3 @@ 96 -type T string //@rename("T", "R", TToR) 97 +type R string //@rename("T", "R", TToR) 98 @@ -6 +6 @@ 99 - T | ~int //@rename("T", "S", TToS) 100 + R | ~int //@rename("T", "S", TToS) 101 -- @TToS/unions.go -- 102 @@ -3 +3 @@ 103 -type T string //@rename("T", "R", TToR) 104 +type S string //@rename("T", "R", TToR) 105 @@ -6 +6 @@ 106 - T | ~int //@rename("T", "S", TToS) 107 + S | ~int //@rename("T", "S", TToS)