blob: ce5db0a615ff0622d783efc8d95b28aa8f4110ef [file] [log] [blame]
Dan Willemsenbc60c3c2021-12-15 01:09:00 -08001// 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
5package p
6
7func f[_ comparable]() {}
8func g[_ interface{interface{comparable; ~int|~string}}]() {}
9
10func _[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 implement comparable */ )]
19 _ = f[R /* ERROR empty interface R does not implement comparable */ ]
20
21 _ = g[int]
22 _ = g[P /* ERROR P does not implement interface{interface{comparable; ~int\|~string} */ ]
23 _ = g[Q]
24 _ = g[func( /* ERROR does not implement comparable */ )]
25 _ = g[R /* ERROR empty interface R does not implement interface{interface{comparable; ~int\|~string} */ ]
26}