|
| 1 | +This test exercises various renaming features on generic code. |
| 2 | + |
| 3 | +Fixed bugs: |
| 4 | + |
| 5 | +- golang/go#61614: renaming a method of a type in a package that uses type |
| 6 | + parameter composite lits used to panic, because previous iterations of the |
| 7 | + satisfy analysis did not account for this language feature. |
| 8 | + |
| 9 | +- golang/go#61635: renaming type parameters did not work when they were |
| 10 | + capitalized and the package was imported by another package. |
| 11 | + |
| 12 | +-- flags -- |
| 13 | +-min_go=go1.18 |
| 14 | + |
| 15 | +-- go.mod -- |
| 16 | +module example.com |
| 17 | +go 1.20 |
| 18 | + |
| 19 | +-- a.go -- |
| 20 | +package a |
| 21 | + |
| 22 | +type I int |
| 23 | + |
| 24 | +func (I) m() {} //@rename("m", M, mToM) |
| 25 | + |
| 26 | +func _[P ~[]int]() { |
| 27 | + _ = P{} |
| 28 | +} |
| 29 | + |
| 30 | +-- @mToM/a.go -- |
| 31 | +package a |
| 32 | + |
| 33 | +type I int |
| 34 | + |
| 35 | +func (I) M() {} //@rename("m", M, mToM) |
| 36 | + |
| 37 | +func _[P ~[]int]() { |
| 38 | + _ = P{} |
| 39 | +} |
| 40 | + |
| 41 | +-- g.go -- |
| 42 | +package a |
| 43 | + |
| 44 | +type S[P any] struct { //@rename("P", Q, PToQ) |
| 45 | + P P |
| 46 | + F func(P) P |
| 47 | +} |
| 48 | + |
| 49 | +func F[R any](r R) { |
| 50 | + var _ R //@rename("R", S, RToS) |
| 51 | +} |
| 52 | + |
| 53 | +-- @PToQ/g.go -- |
| 54 | +package a |
| 55 | + |
| 56 | +type S[Q any] struct { //@rename("P", Q, PToQ) |
| 57 | + P Q |
| 58 | + F func(Q) Q |
| 59 | +} |
| 60 | + |
| 61 | +func F[R any](r R) { |
| 62 | + var _ R //@rename("R", S, RToS) |
| 63 | +} |
| 64 | + |
| 65 | +-- @RToS/g.go -- |
| 66 | +package a |
| 67 | + |
| 68 | +type S[P any] struct { //@rename("P", Q, PToQ) |
| 69 | + P P |
| 70 | + F func(P) P |
| 71 | +} |
| 72 | + |
| 73 | +func F[S any](r S) { |
| 74 | + var _ S //@rename("R", S, RToS) |
| 75 | +} |
| 76 | + |
| 77 | +-- issue61635/p.go -- |
| 78 | +package issue61635 |
| 79 | + |
| 80 | +type builder[S ~[]F, F ~string] struct { //@rename("S", T, SToT) |
| 81 | + name string |
| 82 | + elements S |
| 83 | + elemData map[F][]ElemData[F] |
| 84 | + // other fields... |
| 85 | +} |
| 86 | + |
| 87 | +type ElemData[F ~string] struct { |
| 88 | + Name F |
| 89 | + // other fields... |
| 90 | +} |
| 91 | + |
| 92 | +type BuilderImpl[S ~[]F, F ~string] struct{ builder[S, F] } |
| 93 | + |
| 94 | +-- importer/i.go -- |
| 95 | +package importer |
| 96 | + |
| 97 | +import "example.com/issue61635" // importing is necessary to repro golang/go#61635 |
| 98 | + |
| 99 | +var _ issue61635.ElemData[string] |
| 100 | + |
| 101 | +-- @SToT/issue61635/p.go -- |
| 102 | +package issue61635 |
| 103 | + |
| 104 | +type builder[T ~[]F, F ~string] struct { //@rename("S", T, SToT) |
| 105 | + name string |
| 106 | + elements T |
| 107 | + elemData map[F][]ElemData[F] |
| 108 | + // other fields... |
| 109 | +} |
| 110 | + |
| 111 | +type ElemData[F ~string] struct { |
| 112 | + Name F |
| 113 | + // other fields... |
| 114 | +} |
| 115 | + |
| 116 | +type BuilderImpl[S ~[]F, F ~string] struct{ builder[S, F] } |
| 117 | + |
0 commit comments