...

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

Documentation: internal/types/testdata/fixedbugs

     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  func f1[T any, C chan T | <-chan T](ch C) {}
     8  
     9  func _(ch chan int)   { f1(ch) }
    10  func _(ch <-chan int) { f1(ch) }
    11  func _(ch chan<- int) { f1 /* ERROR "chan<- int does not satisfy chan int | <-chan int" */ (ch) }
    12  
    13  func f2[T any, C chan T | chan<- T](ch C) {}
    14  
    15  func _(ch chan int)   { f2(ch) }
    16  func _(ch <-chan int) { f2 /* ERROR "<-chan int does not satisfy chan int | chan<- int" */ (ch) }
    17  func _(ch chan<- int) { f2(ch) }
    18  

View as plain text