1 // Copyright 2022 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 p
6
7 func f1[_ comparable]() {}
8 func f2[_ interface{ comparable }]() {}
9
10 type T interface{ m() }
11
12 func _[P comparable, Q ~int, R any]() {
13 _ = f1[int]
14 _ = f1[T /* ERROR T does not implement comparable */ ]
15 _ = f1[any /* ERROR any does not implement comparable */ ]
16 _ = f1[P]
17 _ = f1[Q]
18 _ = f1[R /* ERROR R does not implement comparable */]
19
20 _ = f2[int]
21 _ = f2[T /* ERROR T does not implement comparable */ ]
22 _ = f2[any /* ERROR any does not implement comparable */ ]
23 _ = f2[P]
24 _ = f2[Q]
25 _ = f2[R /* ERROR R does not implement comparable */]
26 }
27
View as plain text