| 1 |
Regression test for 'references' bug golang/go#61618: |
| 2 |
references to instantiated fields were missing. |
| 3 |
|
| 4 |
-- go.mod -- |
| 5 |
module example.com |
| 6 |
go 1.18 |
| 7 |
|
| 8 |
-- a.go -- |
| 9 |
package a |
| 10 |
|
| 11 |
// This file is adapted from the example in the issue. |
| 12 |
|
| 13 |
type builder[S ~[]F, F ~string] struct { |
| 14 |
name string |
| 15 |
elements S //@loc(def, "elements"), refs(def, def, assign, use) |
| 16 |
elemData map[F][]ElemData[F] |
| 17 |
} |
| 18 |
|
| 19 |
type ElemData[F ~string] struct { |
| 20 |
Name F |
| 21 |
} |
| 22 |
|
| 23 |
type BuilderImpl[S ~[]F, F ~string] struct{ builder[S, F] } |
| 24 |
|
| 25 |
func NewBuilderImpl[S ~[]F, F ~string](name string) *BuilderImpl[S, F] { |
| 26 |
impl := &BuilderImpl[S,F]{ |
| 27 |
builder[S, F]{ |
| 28 |
name: name, |
| 29 |
elements: S{}, //@loc(assign, "elements"), refs(assign, def, assign, use) |
| 30 |
elemData: map[F][]ElemData[F]{}, |
| 31 |
}, |
| 32 |
} |
| 33 |
|
| 34 |
_ = impl.elements //@loc(use, "elements"), refs(use, def, assign, use) |
| 35 |
return impl |
| 36 |
} |