...

Source file src/internal/types/testdata/spec/comparable.go

Documentation: internal/types/testdata/spec

     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 /* T does satisfy comparable */]
    15  	_ = f1[any /* any does satisfy comparable */]
    16  	_ = f1[P]
    17  	_ = f1[Q]
    18  	_ = f1[R /* ERROR "R does not satisfy comparable" */]
    19  
    20  	_ = f2[int]
    21  	_ = f2[T /* T does satisfy comparable */]
    22  	_ = f2[any /* any does satisfy comparable */]
    23  	_ = f2[P]
    24  	_ = f2[Q]
    25  	_ = f2[R /* ERROR "R does not satisfy comparable" */]
    26  }
    27  

View as plain text