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 import "unsafe"
8
9 // The actual example from the issue.
10 type List[P any] struct{}
11
12 func (_ List[P]) m() (_ List[List[P]]) { return }
13
14 // Other types of recursion through methods.
15 type R[P any] int
16
17 func (*R[R /* ERROR must be an identifier */ [int]]) m0() {}
18 func (R[P]) m1(R[R[P]]) {}
19 func (R[P]) m2(R[*P]) {}
20 func (R[P]) m3([unsafe.Sizeof(new(R[P]))]int) {}
21 func (R[P]) m4([unsafe.Sizeof(new(R[R[P]]))]int) {}
22
23 // Mutual recursion
24 type M[P any] int
25
26 func (R[P]) m5(M[M[P]]) {}
27 func (M[P]) m(R[R[P]]) {}
28
View as plain text