1 // -lang=go1.19 2 3 // Copyright 2022 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package p 8 9 func f1[_ comparable]() {} 10 func f2[_ interface{ comparable }]() {} 11 12 type T interface{ m() } 13 14 func _[P comparable, Q ~int, R any]() { 15 _ = f1[int] 16 _ = f1[T /* ERROR "T to satisfy comparable requires go1.20 or later" */] 17 _ = f1[any /* ERROR "any to satisfy comparable requires go1.20 or later" */] 18 _ = f1[P] 19 _ = f1[Q] 20 _ = f1[R /* ERROR "R does not satisfy comparable" */] 21 22 _ = f2[int] 23 _ = f2[T /* ERROR "T to satisfy comparable requires go1.20 or later" */] 24 _ = f2[any /* ERROR "any to satisfy comparable requires go1.20 or later" */] 25 _ = f2[P] 26 _ = f2[Q] 27 _ = f2[R /* ERROR "R does not satisfy comparable" */] 28 } 29