File tree 1 file changed +15
-4
lines changed
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -2644,10 +2644,21 @@ <h3 id="Type_parameter_declarations">Type parameter declarations</h3>
2644
2644
with a generic type.
2645
2645
</ p >
2646
2646
2647
- <!--
2648
- This section needs to explain if and what kind of cycles are permitted
2649
- using type parameters in a type parameter list.
2650
- -->
2647
+ < p >
2648
+ Within a type parameter list of a generic type < code > T</ code > , a type constraint
2649
+ may not (directly, or indirectly through the type parameter list of another
2650
+ generic type) refer to < code > T</ code > .
2651
+ </ p >
2652
+
2653
+ < pre >
2654
+ type T1[P T1[P]] … // illegal: T1 refers to itself
2655
+ type T2[P interface{ T2[int] }] … // illegal: T2 refers to itself
2656
+ type T3[P interface{ m(T3[int])}] … // illegal: T3 refers to itself
2657
+ type T4[P T5[P]] … // illegal: T4 refers to T5 and
2658
+ type T5[P T4[P]] … // T5 refers to T4
2659
+
2660
+ type T6[P int] struct{ f *T6[P] } // ok: reference to T6 is not in type parameter list
2661
+ </ pre >
2651
2662
2652
2663
< h4 id ="Type_constraints "> Type constraints</ h4 >
2653
2664
You can’t perform that action at this time.
0 commit comments