Debian Codegraph @

src/internal/types/testdata/fixedbugs/issue47796.go

raw
1 // 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
5 package p
6
7 // parameterized types with self-recursive constraints
8 type (
9 T1[P T1[P]] interface{}
10 T2[P, Q T2[P, Q]] interface{}
11 T3[P T2[P, Q], Q interface{ ~string }] interface{}
12
13 T4a[P T4a[P]] interface{ ~int }
14 T4b[P T4b[int]] interface{ ~int }
15 T4c[P T4c[string /* ERROR "string does not satisfy T4c[string]" */]] interface{ ~int }
16
17 // mutually recursive constraints
18 T5[P T6[P]] interface{ int }
19 T6[P T5[P]] interface{ int }
20 )
21
22 // verify that constraints are checked as expected
23 var (
24 _ T1[int]
25 _ T2[int, string]
26 _ T3[int, string]
27 )
28
29 // test case from issue
30
31 type Eq[a Eq[a]] interface {
32 Equal(that a) bool
33 }