blob: 746dfdd2358ba987efc0847035ad6f759151e07f [file] [log] [blame]
Dan Willemsencc753b72021-08-31 13:25:42 -07001// 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
5package generics
6
7func _[A, B any](a A, b B) int {}
8func _[T any](x, y T) T
9
10type T[P any] struct{}
11type T[P1, P2, P3 any] struct{}
12
13type T[P C] struct{}
14type T[P1, P2, P3 C] struct{}
15
16type T[P C[P]] struct{}
17type T[P1, P2, P3 C[P1, P2, P3]] struct{}
18
19func f[P any](x P)
20func f[P1, P2, P3 any](x1 P1, x2 P2, x3 P3) struct{}
21
22func f[P interface{}](x P)
Dan Willemsenbc60c3c2021-12-15 01:09:00 -080023func f[P1, P2, P3 interface{ m1(P1); ~P2|~P3 }](x1 P1, x2 P2, x3 P3) struct{}
Dan Willemsencc753b72021-08-31 13:25:42 -070024func f[P any](T1[P], T2[P]) T3[P]
25
26func (x T[P]) m()
27func ((T[P])) m(x T[P]) P
28
29func _() {
30 type _ []T[P]
31 var _ []T[P]
32 _ = []T[P]{}
33}
34
Dan Willemsenbc60c3c2021-12-15 01:09:00 -080035// type constraint literals with elided interfaces
36func _[P ~int, Q int | string]() {}
37func _[P struct{f int}, Q *P]() {}