Source file src/internal/types/testdata/fixedbugs/issue47115.go

     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  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 <- /* ERRORx `cannot send to ch .* no core type` */ 0
    16  }
    17  
    18  func _[T C0](ch T) {
    19  	ch <- /* ERROR "cannot send to non-channel" */ 0
    20  }
    21  
    22  func _[T C1](ch T) {
    23  	ch <- 0
    24  }
    25  
    26  func _[T C2](ch T) {
    27  	ch  <-/* ERROR "cannot send to receive-only channel" */ 0
    28  }
    29  
    30  func _[T C3](ch T) {
    31  	ch <- /* ERRORx `cannot send to ch .* no core type` */ 0
    32  }
    33  
    34  func _[T C4](ch T) {
    35  	ch <- 0
    36  }
    37  
    38  func _[T C5[X], X any](ch T, x X) {
    39  	ch <- x
    40  }
    41  

View as plain text