~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to test/fixedbugs/issue6847.go

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}