Debian Codegraph @

typeparams/typeparams.go

raw symbols SCIP
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 typeparams
6
7 import (
8 "go/ast"
9 "go/types"
10 )
11
12 // IndexListExpr is an alias for ast.IndexListExpr.
13 //
14 // Deprecated: Use [go/ast.IndexListExpr] instead.
15 //
16 //go:fix inline
17 type IndexListExpr = ast.IndexListExpr
18
19 // ForTypeSpec returns n.TypeParams.
20 func ForTypeSpec(n *ast.TypeSpec) *ast.FieldList {
21 if n == nil {
22 return nil
23 }
24 return n.TypeParams
25 }
26
27 // ForFuncType returns n.TypeParams.
28 func ForFuncType(n *ast.FuncType) *ast.FieldList {
29 if n == nil {
30 return nil
31 }
32 return n.TypeParams
33 }
34
35 // TypeParam is an alias for types.TypeParam
36 //
37 // Deprecated: Use [go/types.TypeParam] instead.
38 //
39 //go:fix inline
40 type TypeParam = types.TypeParam
41
42 // TypeParamList is an alias for types.TypeParamList
43 //
44 // Deprecated: Use [go/types.TypeParamList] instead.
45 //
46 //go:fix inline
47 type TypeParamList = types.TypeParamList
48
49 // TypeList is an alias for types.TypeList
50 //
51 // Deprecated: Use [go/types.TypeList] instead.
52 //
53 //go:fix inline
54 type TypeList = types.TypeList
55
56 // NewTypeParam calls types.NewTypeParam.
57 //
58 // Deprecated: Use [go/types.NewTypeParam] instead.
59 //
60 //go:fix inline
61 func NewTypeParam(name *types.TypeName, constraint types.Type) *TypeParam {
62 return types.NewTypeParam(name, constraint)
63 }
64
65 // NewSignatureType calls types.NewSignatureType.
66 //
67 // Deprecated: Use [go/types.NewSignatureType] instead.
68 //
69 //go:fix inline
70 func NewSignatureType(recv *types.Var, recvTypeParams, typeParams []*TypeParam, params, results *types.Tuple, variadic bool) *types.Signature {
71 return types.NewSignatureType(recv, recvTypeParams, typeParams, params, results, variadic)
72 }
73
74 // ForSignature returns sig.TypeParams()
75 //
76 // Deprecated: Use sig.TypeParams() instead.
77 //
78 //go:fix inline
79 func ForSignature(sig *types.Signature) *TypeParamList {
80 return sig.TypeParams()
81 }
82
83 // RecvTypeParams returns sig.RecvTypeParams().
84 //
85 // Deprecated: Use sig.RecvTypeParams() instead.
86 //
87 //go:fix inline
88 func RecvTypeParams(sig *types.Signature) *TypeParamList {
89 return sig.RecvTypeParams()
90 }
91
92 // IsComparable calls iface.IsComparable().
93 //
94 // Deprecated: Use iface.IsComparable() instead.
95 //
96 //go:fix inline
97 func IsComparable(iface *types.Interface) bool {
98 return iface.IsComparable()
99 }
100
101 // IsMethodSet calls iface.IsMethodSet().
102 //
103 // Deprecated: Use iface.IsMethodSet() instead.
104 //
105 //go:fix inline
106 func IsMethodSet(iface *types.Interface) bool {
107 return iface.IsMethodSet()
108 }
109
110 // IsImplicit calls iface.IsImplicit().
111 //
112 // Deprecated: Use iface.IsImplicit() instead.
113 //
114 //go:fix inline
115 func IsImplicit(iface *types.Interface) bool {
116 return iface.IsImplicit()
117 }
118
119 // MarkImplicit calls iface.MarkImplicit().
120 //
121 // Deprecated: Use iface.MarkImplicit() instead.
122 //
123 //go:fix inline
124 func MarkImplicit(iface *types.Interface) {
125 iface.MarkImplicit()
126 }
127
128 // ForNamed extracts the (possibly empty) type parameter object list from
129 // named.
130 //
131 // Deprecated: Use named.TypeParams() instead.
132 //
133 //go:fix inline
134 func ForNamed(named *types.Named) *TypeParamList {
135 return named.TypeParams()
136 }
137
138 // SetForNamed sets the type params tparams on n. Each tparam must be of
139 // dynamic type *types.TypeParam.
140 //
141 // Deprecated: Use n.SetTypeParams(...) instead.
142 //
143 //go:fix inline
144 func SetForNamed(n *types.Named, tparams []*TypeParam) {
145 n.SetTypeParams(tparams)
146 }
147
148 // NamedTypeArgs returns named.TypeArgs().
149 //
150 // Deprecated: Use named.TypeArgs() instead.
151 //
152 //go:fix inline
153 func NamedTypeArgs(named *types.Named) *TypeList {
154 return named.TypeArgs()
155 }
156
157 // NamedTypeOrigin returns named.Orig().
158 //
159 // Deprecated: Use named.Origin() instead.
160 //
161 //go:fix inline
162 func NamedTypeOrigin(named *types.Named) types.Type {
163 return named.Origin()
164 }
165
166 // Term is an alias for types.Term.
167 //
168 // Deprecated: Use [go/types.Term] instead.
169 //
170 //go:fix inline
171 type Term = types.Term
172
173 // NewTerm calls types.NewTerm.
174 //
175 // Deprecated: Use [go/types.NewTerm] instead.
176 //
177 //go:fix inline
178 func NewTerm(tilde bool, typ types.Type) *Term {
179 return types.NewTerm(tilde, typ)
180 }
181
182 // Union is an alias for types.Union
183 //
184 // Deprecated: Use [go/types.Union] instead.
185 //
186 //go:fix inline
187 type Union = types.Union
188
189 // NewUnion calls types.NewUnion.
190 //
191 // Deprecated: Use [go/types.NewUnion] instead.
192 //
193 //go:fix inline
194 func NewUnion(terms []*Term) *Union {
195 return types.NewUnion(terms)
196 }
197
198 // InitInstances initializes info to record information about type and function
199 // instances.
200 //
201 // Deprecated: Use info.Instances = make(...) instead.
202 //
203 //go:fix inline
204 func InitInstances(info *types.Info) {
205 info.Instances = make(map[*ast.Ident]types.Instance)
206 }
207
208 // Instance is an alias for types.Instance.
209 //
210 // Deprecated: Use [go/types.Instance] instead.
211 //
212 //go:fix inline
213 type Instance = types.Instance
214
215 // GetInstances returns info.Instances.
216 //
217 // Deprecated: Use info.Instances instead.
218 //
219 //go:fix inline
220 func GetInstances(info *types.Info) map[*ast.Ident]Instance {
221 return info.Instances
222 }
223
224 // Context is an alias for types.Context.
225 //
226 // Deprecated: Use [go/types.Context] instead.
227 //
228 //go:fix inline
229 type Context = types.Context
230
231 // NewContext calls types.NewContext.
232 //
233 // Deprecated: Use [go/types.NewContext] instead.
234 //
235 //go:fix inline
236 func NewContext() *Context {
237 return types.NewContext()
238 }
239
240 // Instantiate calls types.Instantiate.
241 //
242 // Deprecated: Use [go/types.Instantiate] instead.
243 //
244 //go:fix inline
245 func Instantiate(ctxt *Context, typ types.Type, targs []types.Type, validate bool) (types.Type, error) {
246 return types.Instantiate(ctxt, typ, targs, validate)
247 }