Source file src/internal/types/testdata/fixedbugs/issue47411.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  func f[_ comparable]() {}
     8  func g[_ interface{interface{comparable; ~int|~string}}]() {}
     9  
    10  func _[P comparable,
    11          Q interface{ comparable; ~int|~string },
    12          R any,                               // not comparable
    13          S interface{ comparable; ~func() },  // not comparable
    14  ]() {
    15          _ = f[int]
    16          _ = f[P]
    17          _ = f[Q]
    18          _ = f[func /* ERROR "does not satisfy comparable" */ ()]
    19          _ = f[R /* ERROR "R does not satisfy comparable" */ ]
    20  
    21          _ = g[int]
    22          _ = g[P /* ERROR "P does not satisfy interface{interface{comparable; ~int | ~string}" */ ]
    23          _ = g[Q]
    24          _ = g[func /* ERROR "func() does not satisfy interface{interface{comparable; ~int | ~string}}" */ ()]
    25          _ = g[R /* ERROR "R does not satisfy interface{interface{comparable; ~int | ~string}" */ ]
    26  }
    27  

View as plain text