| 1 | // Copyright 2021 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // go:build ignore |
| 6 | |
| 7 | package testdata |
| 8 | |
| 9 | type I1 interface{} |
| 10 | type I2 interface{} |
| 11 | type I3 interface{} |
| 12 | |
| 13 | func Foo[C interface{ ~chan I1 | ~chan<- I1 }](c C, j int) { |
| 14 | c <- j |
| 15 | } |
| 16 | |
| 17 | func Bar[C interface{ ~chan I2 | ~<-chan I2 }](c C) { |
| 18 | x := <-c |
| 19 | print(x) |
| 20 | } |
| 21 | |
| 22 | func Baz[C interface{ ~chan I3 | ~<-chan I3 }](c C) { |
| 23 | select { |
| 24 | case x := <-c: |
| 25 | print(x) |
| 26 | default: |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // WANT: |
| 31 | // Local(t0) -> Channel(chan testdata.I1) |
| 32 | // Channel(chan testdata.I2) -> Local(t0) |
| 33 | // Channel(chan testdata.I3) -> Local(t0[2]) |