1// run 2 3// Copyright 2020 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 7package main 8 9func main() { 10 { 11 i := I(A{}) 12 13 b := make(chan I, 1) 14 b <- B{} 15 16 var ok bool 17 i, ok = <-b 18 _ = ok 19 20 i.M() 21 } 22 23 { 24 i := I(A{}) 25 26 b := make(chan I, 1) 27 b <- B{} 28 29 select { 30 case i = <-b: 31 } 32 33 i.M() 34 } 35 36 { 37 i := I(A{}) 38 39 b := make(chan I, 1) 40 b <- B{} 41 42 var ok bool 43 select { 44 case i, ok = <-b: 45 } 46 _ = ok 47 48 i.M() 49 } 50} 51 52type I interface{ M() int } 53 54type T int 55 56func (T) M() int { return 0 } 57 58type A struct{ T } 59type B struct{ T } 60