Text file src/cmd/gofmt/testdata/typeparams.input

     1  // Copyright 2020 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  //gofmt
     6  
     7  package typeparams
     8  
     9  type T[  P any] struct{}
    10  type T[P1, P2, P3 any] struct{}
    11  
    12  type T[P C] struct{}
    13  type T[P1,P2, P3 C] struct{}
    14  
    15  type T[P C[P]] struct{}
    16  type T[P1, P2, P3 C[P1,P2,P3]] struct{}
    17  
    18  func f[P any](x P)
    19  func f[P1, P2, P3 any](x1 P1, x2 P2, x3 P3) struct{}
    20  
    21  func f[P interface{}](x P)
    22  func f[P1, P2, P3 interface{ m1(P1); ~P2|~P3 }](x1 P1, x2 P2, x3 P3) struct{}
    23  func f[P any](T1[P], T2[P]) T3[P]
    24  
    25  func (x T[P]) m()
    26  func ((T[P])) m(x T[P]) P
    27  
    28  func _() {
    29  	type _ []T[P]
    30  	var _ []T[P]
    31  	_ = []T[P]{}
    32  }
    33  

View as plain text