Black Lives Matter. Support the Equal Justice Initiative.

Text file src/go/printer/testdata/generics.input

Documentation: go/printer/testdata

     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  package generics
     6  
     7  func _[A, B any](a A, b B) int {}
     8  func _[T any](x, y T) T
     9  
    10  type T[P any] struct{}
    11  type T[P1, P2, P3 any] struct{}
    12  
    13  type T[P C] struct{}
    14  type T[P1, P2, P3 C] struct{}
    15  
    16  type T[P C[P]] struct{}
    17  type T[P1, P2, P3 C[P1, P2, P3]] struct{}
    18  
    19  func f[P any](x P)
    20  func f[P1, P2, P3 any](x1 P1, x2 P2, x3 P3) struct{}
    21  
    22  func f[P interface{}](x P)
    23  func f[P1, P2, P3 interface{ m1(P1); type P2, P3 }](x1 P1, x2 P2, x3 P3) struct{}
    24  func f[P any](T1[P], T2[P]) T3[P]
    25  
    26  func (x T[P]) m()
    27  func ((T[P])) m(x T[P]) P
    28  
    29  func _() {
    30  	type _ []T[P]
    31  	var _ []T[P]
    32  	_ = []T[P]{}
    33  }
    34  
    35  // properly format one-line type lists
    36  type _ interface { type a }
    37  
    38  type _ interface { type a,b,c }
    39  

View as plain text