aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/lsp/testdata/fillstruct/typeparams.go
blob: c0b702f57c7b5fe287f8e5a9bf85262eb64289fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//go:build go1.18
// +build go1.18

package fillstruct

type emptyStructWithTypeParams[A any] struct{}

var _ = emptyStructWithTypeParams[int]{} // no suggested fix

type basicStructWithTypeParams[T any] struct {
	foo T
}

var _ = basicStructWithTypeParams[int]{} //@suggestedfix("}", "refactor.rewrite", "Fill")

type twoArgStructWithTypeParams[F, B any] struct {
	foo F
	bar B
}

var _ = twoArgStructWithTypeParams[string, int]{} //@suggestedfix("}", "refactor.rewrite", "Fill")

var _ = twoArgStructWithTypeParams[int, string]{
	bar: "bar",
} //@suggestedfix("}", "refactor.rewrite", "Fill")

type nestedStructWithTypeParams struct {
	bar   string
	basic basicStructWithTypeParams[int]
}

var _ = nestedStructWithTypeParams{} //@suggestedfix("}", "refactor.rewrite", "Fill")

func _[T any]() {
	type S struct{ t T }
	_ = S{} //@suggestedfix("}", "refactor.rewrite", "Fill")
}