github.com/remobjects/goldbaselibrary@v0.0.0-20230924164425-d458680a936b/Source/Gold/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  import "unsafe"
     8  
     9  type (
    10  	T0 int
    11  	T1 /* ERROR cycle */ T1
    12  	T2 *T2
    13  
    14  	T3 /* ERROR cycle */ T4
    15  	T4 T5
    16  	T5 T3
    17  
    18  	T6 T7
    19  	T7 *T8
    20  	T8 T6
    21  
    22  	// arrays
    23  	A0 /* ERROR cycle */ [10]A0
    24  	A1 [10]*A1
    25  
    26  	A2 /* ERROR cycle */ [10]A3
    27  	A3 [10]A4
    28  	A4 A2
    29  
    30  	A5 [10]A6
    31  	A6 *A5
    32  
    33  	// slices
    34  	L0 []L0
    35  
    36  	// structs
    37  	S0 /* ERROR cycle */ struct{ _ S0 }
    38  	S1 /* ERROR cycle */ struct{ S1 }
    39  	S2 struct{ _ *S2 }
    40  	S3 struct{ *S3 }
    41  
    42  	S4 /* ERROR cycle */ struct{ S5 }
    43  	S5 struct{ S6 }
    44  	S6 S4
    45  
    46  	// pointers
    47  	P0 *P0
    48  
    49  	// functions
    50  	F0 func(F0)
    51  	F1 func() F1
    52  	F2 func(F2) F2
    53  
    54  	// interfaces
    55  	I0 /* ERROR cycle */ interface{ I0 }
    56  
    57  	I1 /* ERROR cycle */ interface{ I2 }
    58  	I2 interface{ I3 }
    59  	I3 interface{ I1 }
    60  
    61  	I4 interface{ f(I4) }
    62  
    63  	// testcase for issue 5090
    64  	I5 interface{ f(I6) }
    65  	I6 interface{ I5 }
    66  
    67  	// maps
    68  	M0 map[M0 /* ERROR invalid map key */ ]M0
    69  
    70  	// channels
    71  	C0 chan C0
    72  )
    73  
    74  func _() {
    75  	type (
    76  		t1 /* ERROR cycle */ t1
    77  		t2 *t2
    78  
    79  		t3 t4 /* ERROR undeclared */
    80  		t4 t5 /* ERROR undeclared */
    81  		t5 t3
    82  
    83  		// arrays
    84  		a0 /* ERROR cycle */ [10]a0
    85  		a1 [10]*a1
    86  
    87  		// slices
    88  		l0 []l0
    89  
    90  		// structs
    91  		s0 /* ERROR cycle */ struct{ _ s0 }
    92  		s1 /* ERROR cycle */ struct{ s1 }
    93  		s2 struct{ _ *s2 }
    94  		s3 struct{ *s3 }
    95  
    96  		// pointers
    97  		p0 *p0
    98  
    99  		// functions
   100  		f0 func(f0)
   101  		f1 func() f1
   102  		f2 func(f2) f2
   103  
   104  		// interfaces
   105  		i0 /* ERROR cycle */ interface{ i0 }
   106  
   107  		// maps
   108  		m0 map[m0 /* ERROR invalid map key */ ]m0
   109  
   110  		// channels
   111  		c0 chan c0
   112  	)
   113  }
   114  
   115  // test cases for issue 6667
   116  
   117  type A [10]map[A /* ERROR invalid map key */ ]bool
   118  
   119  type S struct {
   120  	m map[S /* ERROR invalid map key */ ]bool
   121  }
   122  
   123  // test cases for issue 7236
   124  // (cycle detection must not be dependent on starting point of resolution)
   125  
   126  type (
   127  	P1 *T9
   128  	T9 /* ERROR cycle */ T9
   129  
   130  	T10 /* ERROR cycle */ T10
   131  	P2 *T10
   132  )
   133  
   134  func (T11) m() {}
   135  
   136  type T11 /* ERROR cycle */ struct{ T11 }
   137  
   138  type T12 /* ERROR cycle */ struct{ T12 }
   139  
   140  func (*T12) m() {}
   141  
   142  type (
   143  	P3 *T13
   144  	T13 /* ERROR cycle */ T13
   145  )
   146  
   147  // test cases for issue 18643
   148  // (type cycle detection when non-type expressions are involved)
   149  type (
   150  	T14 /* ERROR cycle */ [len(T14{})]int
   151  	T15 [][len(T15 /* ERROR cycle */ {})]int
   152  	T16 map[[len(T16 /* ERROR cycle */ {1:2})]int]int
   153  	T17 map[int][len(T17 /* ERROR cycle */ {1:2})]int
   154  )
   155  
   156  // Test case for types depending on function literals (see also #22992).
   157  type T20 chan [unsafe.Sizeof(func(ch T20){ _ = <-ch })]byte
   158  type T22 = chan [unsafe.Sizeof(func(ch T20){ _ = <-ch })]byte
   159  
   160  func _() {
   161  	type T0 func(T0)
   162  	type T1 /* ERROR cycle */ = func(T1)
   163  	type T2 chan [unsafe.Sizeof(func(ch T2){ _ = <-ch })]byte
   164  	type T3 /* ERROR cycle */ = chan [unsafe.Sizeof(func(ch T3){ _ = <-ch })]byte
   165  }