1 // Copyright 2020 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 // Check "infinite expansion" cycle errors across instantiated types.
6
7 package p
8
9 type E0[P any] P
10 type E1[P any] *P
11 type E2[P any] struct{ P }
12 type E3[P any] struct{ *P }
13
14 type T0 /* ERROR illegal cycle */ struct {
15 _ E0[T0]
16 }
17
18 type T0_ /* ERROR illegal cycle */ struct {
19 E0[T0_]
20 }
21
22 type T1 struct {
23 _ E1[T1]
24 }
25
26 type T2 /* ERROR illegal cycle */ struct {
27 _ E2[T2]
28 }
29
30 type T3 struct {
31 _ E3[T3]
32 }
33
34 // some more complex cases
35
36 type T4 /* ERROR illegal cycle */ struct {
37 _ E0[E2[T4]]
38 }
39
40 type T5 struct {
41 _ E0[E2[E0[E1[E2[[10]T5]]]]]
42 }
43
44 type T6 /* ERROR illegal cycle */ struct {
45 _ E0[[10]E2[E0[E2[E2[T6]]]]]
46 }
47
48 type T7 struct {
49 _ E0[[]E2[E0[E2[E2[T6]]]]]
50 }
51
View as plain text