]> Cypherpunks.ru repositories - gostls13.git/blob - test/fixedbugs/issue6847.go
e6427e19acf0251c59451640b9898948c2f412ce
[gostls13.git] / test / fixedbugs / issue6847.go
1 // compile
2
3 // Copyright 2014 The Go Authors.  All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // Issue 6847: select clauses involving implicit conversion
8 // of channels trigger a spurious typechecking error during walk.
9
10 package p
11
12 type I1 interface {
13         String()
14 }
15 type I2 interface {
16         String()
17 }
18
19 func F() {
20         var (
21                 cr <-chan int
22                 cs chan<- int
23                 c  chan int
24
25                 ccr chan (<-chan int)
26                 ccs chan chan<- int
27                 cc  chan chan int
28
29                 ok bool
30         )
31         // Send cases.
32         select {
33         case ccr <- cr:
34         case ccr <- c:
35         }
36         select {
37         case ccs <- cs:
38         case ccs <- c:
39         }
40         select {
41         case ccr <- c:
42         default:
43         }
44         // Receive cases.
45         select {
46         case cr = <-cc:
47         case cs = <-cc:
48         case c = <-cc:
49         }
50         select {
51         case cr = <-cc:
52         default:
53         }
54         select {
55         case cr, ok = <-cc:
56         case cs, ok = <-cc:
57         case c = <-cc:
58         }
59       // Interfaces.
60         var (
61                 c1 chan I1
62                 c2 chan I2
63                 x1 I1
64                 x2 I2
65         )
66         select {
67         case c1 <- x1:
68         case c1 <- x2:
69         case c2 <- x1:
70         case c2 <- x2:
71         }
72         select {
73         case x1 = <-c1:
74         case x1 = <-c2:
75         case x2 = <-c1:
76         case x2 = <-c2:
77         }
78         select {
79         case x1, ok = <-c1:
80         case x1, ok = <-c2:
81         case x2, ok = <-c1:
82         case x2, ok = <-c2:
83         }
84         _ = ok
85 }