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

     1  // Copyright 2026 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 g[T any](T) {}
     8  
     9  func _() {
    10  	type F func(int)
    11  	_ = struct{ f F }{f: g}
    12  	_ = [42]F{g}
    13  	_ = []F{g}
    14  	_ = map[int]F{42: g}
    15  	_ = F(g)
    16  	make(chan F) <- g
    17  }
    18  
    19  func _[F func(int)]() {
    20  	_ = struct{ f F }{f: g}
    21  	_ = [42]F{g}
    22  	_ = []F{g}
    23  	_ = map[int]F{42: g}
    24  	_ = F(g)
    25  	make(chan F) <- g
    26  }
    27  
    28  func _[F func(int) | func(uint)]() {
    29  	_ = struct{ f F }{f: g /* ERROR "cannot use generic function g" */}
    30  	_ = [42]F{g /* ERROR "cannot use generic function g" */}
    31  	_ = []F{g /* ERROR "cannot use generic function g" */}
    32  	_ = map[int]F{42: g /* ERROR "cannot use generic function g" */}
    33  	_ = F(g /* ERROR "cannot use generic function g" */)
    34  	make(chan F) <- g /* ERROR "cannot use generic function g" */
    35  }
    36  

View as plain text