1
2
3
4
5
6
7
8
9
10 package main
11
12 func main() {
13 F[int]()
14 F[string]()
15 }
16
17 func F[X any]() {
18 call(T[X].M, T[X].N)
19 }
20
21 func call[X any](fns ...func(T[X]) int) {
22 for want, fn := range fns {
23 if have := fn(T[X]{}); have != want {
24 println("FAIL:", have, "!=", want)
25 }
26 }
27 }
28
29 type T[X any] struct {
30 E1
31 *E2[*X]
32 }
33
34 type E1 struct{}
35 type E2[_ any] struct{}
36
37 func (E1) M() int { return 0 }
38 func (*E2[_]) N() int { return 1 }
39
View as plain text