1
2
3
4
5 package types2
6
7
8 type TypeParamList struct{ tparams []*TypeParam }
9
10
11
12 func (l *TypeParamList) Len() int { return len(l.list()) }
13
14
15 func (l *TypeParamList) At(i int) *TypeParam { return l.tparams[i] }
16
17
18
19
20 func (l *TypeParamList) list() []*TypeParam {
21 if l == nil {
22 return nil
23 }
24 return l.tparams
25 }
26
27
28 type TypeList struct{ types []Type }
29
30
31 func newTypeList(list []Type) *TypeList {
32 if len(list) == 0 {
33 return nil
34 }
35 return &TypeList{list}
36 }
37
38
39
40 func (l *TypeList) Len() int { return len(l.list()) }
41
42
43 func (l *TypeList) At(i int) Type { return l.types[i] }
44
45
46
47
48 func (l *TypeList) list() []Type {
49 if l == nil {
50 return nil
51 }
52 return l.types
53 }
54
55
56
57
58 func bindTParams(list []*TypeParam) *TypeParamList {
59 if len(list) == 0 {
60 return nil
61 }
62 for i, typ := range list {
63 if typ.index >= 0 {
64 panic("type parameter bound more than once")
65 }
66 typ.index = i
67 }
68 return &TypeParamList{tparams: list}
69 }
70
View as plain text