Text file src/go/types/testdata/fixedbugs/issue47127.go2

     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  // Embedding of stand-alone type parameters is not permitted.
     6  
     7  package p
     8  
     9  type (
    10          _[P any] interface{ *P | []P | chan P | map[string]P }
    11          _[P any] interface{ P /* ERROR "cannot embed a type parameter" */ }
    12          _[P any] interface{ ~P /* ERROR "cannot embed a type parameter" */ }
    13          _[P any] interface{ int | P /* ERROR "cannot embed a type parameter" */ }
    14          _[P any] interface{ int | ~P /* ERROR "cannot embed a type parameter" */ }
    15  )
    16  
    17  func _[P any]() {
    18          type (
    19                  _[P any] interface{ *P | []P | chan P | map[string]P }
    20                  _[P any] interface{ P /* ERROR "cannot embed a type parameter" */ }
    21                  _[P any] interface{ ~P /* ERROR "cannot embed a type parameter" */ }
    22                  _[P any] interface{ int | P /* ERROR "cannot embed a type parameter" */ }
    23                  _[P any] interface{ int | ~P /* ERROR "cannot embed a type parameter" */ }
    24  
    25                  _ interface{ *P | []P | chan P | map[string]P }
    26                  _ interface{ P /* ERROR "cannot embed a type parameter" */ }
    27                  _ interface{ ~P /* ERROR "cannot embed a type parameter" */ }
    28                  _ interface{ int | P /* ERROR "cannot embed a type parameter" */ }
    29                  _ interface{ int | ~P /* ERROR "cannot embed a type parameter" */ }
    30          )
    31  }
    32  
    33  func _[P any, Q interface{ *P | []P | chan P | map[string]P }]() {}
    34  func _[P any, Q interface{ P /* ERROR "cannot embed a type parameter" */ }]() {}
    35  func _[P any, Q interface{ ~P /* ERROR "cannot embed a type parameter" */ }]() {}
    36  func _[P any, Q interface{ int | P /* ERROR "cannot embed a type parameter" */ }]() {}
    37  func _[P any, Q interface{ int | ~P /* ERROR "cannot embed a type parameter" */ }]() {}
    38  

View as plain text