1
2
3
4
5
6
7 package p
8
9
10 type B[P any] struct{}
11 type _[P interface{}] struct{}
12 type _[P B] struct{}
13 type _[P B[P]] struct{}
14
15 type _[A, B, C any] struct{}
16 type _[A, B, C B] struct{}
17 type _[A, B, C B[A, B, C]] struct{}
18 type _[A1, A2 B1, A3 B2, A4, A5, A6 B3] struct{}
19
20 type _[A interface{}] struct{}
21 type _[A, B interface{ m() }] struct{}
22
23 type _[A, B, C any] struct{}
24
25
26 func _[P any]()
27 func _[P interface{}]()
28 func _[P B]()
29 func _[P B[P]]()
30
31
32 type _ T[int]
33
34
35 var _ = T[int]{}
36
37
38 type _ struct{ T[int] }
39
40
41 type _ interface {
42 m()
43 ~int
44 }
45
46 type _ interface {
47 ~int | ~float | ~string
48 ~complex128
49 underlying(underlying underlying) underlying
50 }
51
52 type _ interface {
53 T
54 T[int]
55 }
56
57
58 func _(T[P], T[P1, P2])
59 func _(a [N]T)
60
61 type _ struct {
62 T[P]
63 T[P1, P2]
64 f[N]
65 }
66 type _ interface {
67 m()
68
69
70 T[ ]
71 T[P]
72 T[P1, P2]
73 }
74
75
76 type List[E any] []E
77
78 func (l List[E]) Map[F any](m func(E) F) (r List[F]) {
79 for _, x := range l {
80 r = append(r, m(x))
81 }
82 return
83 }
84
85 func _() {
86 l := List[string]{"foo", "foobar", "42"}
87 r := l.Map(func(s string) int { return len(s)})
88 _ = r
89 }
90
91 func _[E, F any](l List[E]) List[F] {
92 var f func(List[E], func(E) F) List[F] = List[E].Map
93 return f(l, func(E) F { var f F; return f })
94 }
95
96
97
98 type _ func [P any](P)
99 type _ interface {
100 m [P any](P)
101 }
102
103 var _ = func [P any](P) {}
104
View as plain text