github.com/q45/go@v0.0.0-20151101211701-a4fb8c13db3f/src/go/types/testdata/cycles.src (about) 1 // Copyright 2013 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 cycles 6 7 type ( 8 T0 int 9 T1 /* ERROR cycle */ T1 10 T2 *T2 11 12 T3 /* ERROR cycle */ T4 13 T4 T5 14 T5 T3 15 16 T6 T7 17 T7 *T8 18 T8 T6 19 20 // arrays 21 A0 /* ERROR cycle */ [10]A0 22 A1 [10]*A1 23 24 A2 /* ERROR cycle */ [10]A3 25 A3 [10]A4 26 A4 A2 27 28 A5 [10]A6 29 A6 *A5 30 31 // slices 32 L0 []L0 33 34 // structs 35 S0 /* ERROR cycle */ struct{ _ S0 } 36 S1 /* ERROR cycle */ struct{ S1 } 37 S2 struct{ _ *S2 } 38 S3 struct{ *S3 } 39 40 S4 /* ERROR cycle */ struct{ S5 } 41 S5 struct{ S6 } 42 S6 S4 43 44 // pointers 45 P0 *P0 46 47 // functions 48 F0 func(F0) 49 F1 func() F1 50 F2 func(F2) F2 51 52 // interfaces 53 I0 /* ERROR cycle */ interface{ I0 } 54 55 I1 interface{ I2 } 56 I2 interface{ I3 } 57 I3 /* ERROR cycle */ interface{ I1 } 58 59 I4 interface{ f(I4) } 60 61 // testcase for issue 5090 62 I5 interface{ f(I6) } 63 I6 interface{ I5 } 64 65 // maps 66 M0 map[M0 /* ERROR invalid map key */ ]M0 67 68 // channels 69 C0 chan C0 70 ) 71 72 func _() { 73 type ( 74 t1 /* ERROR cycle */ t1 75 t2 *t2 76 77 t3 t4 /* ERROR undeclared */ 78 t4 t5 /* ERROR undeclared */ 79 t5 t3 80 81 // arrays 82 a0 /* ERROR cycle */ [10]a0 83 a1 [10]*a1 84 85 // slices 86 l0 []l0 87 88 // structs 89 s0 /* ERROR cycle */ struct{ _ s0 } 90 s1 /* ERROR cycle */ struct{ s1 } 91 s2 struct{ _ *s2 } 92 s3 struct{ *s3 } 93 94 // pointers 95 p0 *p0 96 97 // functions 98 f0 func(f0) 99 f1 func() f1 100 f2 func(f2) f2 101 102 // interfaces 103 i0 /* ERROR cycle */ interface{ i0 } 104 105 // maps 106 m0 map[m0 /* ERROR invalid map key */ ]m0 107 108 // channels 109 c0 chan c0 110 ) 111 } 112 113 // test cases for issue 6667 114 115 type A [10]map[A /* ERROR invalid map key */ ]bool 116 117 type S struct { 118 m map[S /* ERROR invalid map key */ ]bool 119 } 120 121 // test cases for issue 7236 122 // (cycle detection must not be dependent on starting point of resolution) 123 124 type ( 125 P1 *T9 126 T9 /* ERROR cycle */ T9 127 128 T10 /* ERROR cycle */ T10 129 P2 *T10 130 ) 131 132 func (T11) m() {} 133 134 type T11 /* ERROR cycle */ struct{ T11 } 135 136 type T12 /* ERROR cycle */ struct{ T12 } 137 138 func (*T12) m() {} 139 140 type ( 141 P3 *T13 142 T13 /* ERROR cycle */ T13 143 )