...
1
2
3
4
5 package p
6
7 type C0 interface{ int }
8 type C1 interface{ chan int }
9 type C2 interface{ chan int | <-chan int }
10 type C3 interface{ chan int | chan float32 }
11 type C4 interface{ chan int | chan<- int }
12 type C5[T any] interface{ ~chan T | <-chan T }
13
14 func _[T any](ch T) {
15 <-ch
16 }
17
18 func _[T C0](ch T) {
19 <-ch
20 }
21
22 func _[T C1](ch T) {
23 <-ch
24 }
25
26 func _[T C2](ch T) {
27 <-ch
28 }
29
30 func _[T C3](ch T) {
31 <-ch
32 }
33
34 func _[T C4](ch T) {
35 <-ch
36 }
37
38 func _[T C5[X], X any](ch T, x X) {
39 x = <-ch
40 }
41
42
43 type RecvChan[T any] interface {
44 ~chan T | ~<-chan T
45 }
46
47 func _[T any, C RecvChan[T]](ch C) T {
48 return <-ch
49 }
50
51 func f[T any, C interface{ chan T }](ch C) T {
52 return <-ch
53 }
54
55 func _(ch chan int) {
56 var x int = f(ch)
57 _ = x
58 }
59
View as plain text