@@ -269,47 +269,47 @@ class Type {
269
269
// / its children.
270
270
bool findIf (llvm::function_ref<bool (Type)> pred) const ;
271
271
272
- // / Transform the given type by applying the user-provided function to
273
- // / each type .
272
+ // / Transform the given type by recursively applying the user-provided
273
+ // / function to each node .
274
274
// /
275
- // / This routine applies the given function to transform one type into
276
- // / another. If the function leaves the type unchanged, recurse into the
277
- // / child type nodes and transform those. If any child type node changes,
278
- // / the parent type node will be rebuilt.
279
- // /
280
- // / If at any time the function returns a null type, the null will be
281
- // / propagated out.
282
- // /
283
- // / \param fn A function object with the signature \c Type(Type), which
284
- // / accepts a type and returns either a transformed type or a null type.
275
+ // / \param fn A function object with the signature \c Type(Type) , which
276
+ // / accepts a type and returns either a transformed type or a null type
277
+ // / (which will propagate out the null type).
285
278
// /
286
279
// / \returns the result of transforming the type.
287
280
Type transform (llvm::function_ref<Type(Type)> fn) const ;
288
281
289
- // / Transform the given type by applying the user-provided function to
290
- // / each type.
291
- // /
292
- // / This routine applies the given function to transform one type into
293
- // / another. If the function leaves the type unchanged, recurse into the
294
- // / child type nodes and transform those. If any child type node changes,
295
- // / the parent type node will be rebuilt.
296
- // /
297
- // / If at any time the function returns a null type, the null will be
298
- // / propagated out.
282
+ // / Transform the given type by recursively applying the user-provided
283
+ // / function to each node.
299
284
// /
300
285
// / If the function returns \c None, the transform operation will
301
286
// /
302
- // / \param fn A function object with the signature
303
- // / \c Optional<Type>(TypeBase *), which accepts a type pointer and returns a
304
- // / transformed type, a null type (which will propagate the null type to the
305
- // / outermost \c transform() call), or None (to indicate that the transform
306
- // / operation should recursively transform the subtypes). The function object
307
- // / should use \c dyn_cast rather \c getAs, because the transform itself
308
- // / handles desugaring.
287
+ // / \param fn A function object which accepts a type pointer and returns a
288
+ // / transformed type, a null type (which will propagate out the null type),
289
+ // / or None (to indicate that the transform operation should recursively
290
+ // / transform the children). The function object should use \c dyn_cast rather
291
+ // / than \c getAs when the transform is intended to preserve sugar
309
292
// /
310
293
// / \returns the result of transforming the type.
311
294
Type transformRec (llvm::function_ref<Optional<Type>(TypeBase *)> fn) const ;
312
295
296
+ // / Transform the given type by recursively applying the user-provided
297
+ // / function to each node.
298
+ // /
299
+ // / \param pos The variance position of the receiver.
300
+ // /
301
+ // / \param fn A function object which accepts a type pointer along with its
302
+ // / variance position and returns either a transformed type, a null type
303
+ // / (which will propagate out the null type), or \c None (to indicate that the
304
+ // / transform operation should recursively transform the children).
305
+ // / The function object should use \c dyn_cast rather than \c getAs when the
306
+ // / transform is intended to preserve sugar.
307
+ // /
308
+ // / \returns the result of transforming the type.
309
+ Type transformWithPosition (
310
+ TypePosition pos,
311
+ llvm::function_ref<Optional<Type>(TypeBase *, TypePosition)> fn) const ;
312
+
313
313
// / Look through the given type and its children and apply fn to them.
314
314
void visit (llvm::function_ref<void (Type)> fn) const {
315
315
findIf ([&fn](Type t) -> bool {
0 commit comments