@@ -40,7 +40,9 @@ struct PackTypeParameterCollector: TypeWalker {
40
40
if (auto parentType = boundGenericType->getParent ())
41
41
parentType.walk (*this );
42
42
43
- Type (boundGenericType->getExpandedGenericArgsPack ()).walk (*this );
43
+ for (auto type : boundGenericType->getExpandedGenericArgs ())
44
+ type.walk (*this );
45
+
44
46
return Action::SkipChildren;
45
47
}
46
48
@@ -49,7 +51,9 @@ struct PackTypeParameterCollector: TypeWalker {
49
51
if (auto parentType = typeAliasType->getParent ())
50
52
parentType.walk (*this );
51
53
52
- Type (typeAliasType->getExpandedGenericArgsPack ()).walk (*this );
54
+ for (auto type : typeAliasType->getExpandedGenericArgs ())
55
+ type.walk (*this );
56
+
53
57
return Action::SkipChildren;
54
58
}
55
59
}
@@ -244,7 +248,7 @@ unsigned ParameterList::getOrigParamIndex(SubstitutionMap subMap,
244
248
}
245
249
246
250
// / <T...> Foo<T, Pack{Int, String}> => Pack{T..., Int, String}
247
- PackType * BoundGenericType::getExpandedGenericArgsPack () {
251
+ SmallVector<Type, 2 > BoundGenericType::getExpandedGenericArgs () {
248
252
// It would be nicer to use genericSig.getInnermostGenericParams() here,
249
253
// but that triggers a request cycle if we're in the middle of computing
250
254
// the generic signature already.
@@ -253,26 +257,26 @@ PackType *BoundGenericType::getExpandedGenericArgsPack() {
253
257
params.push_back (paramDecl->getDeclaredInterfaceType ());
254
258
}
255
259
256
- return PackType::get ( getASTContext (),
260
+ return PackType::getExpandedGenericArgs (
257
261
TypeArrayView<GenericTypeParamType>(params),
258
262
getGenericArgs ());
259
263
}
260
264
261
265
// / <T...> Foo<T, Pack{Int, String}> => Pack{T..., Int, String}
262
- PackType * TypeAliasType::getExpandedGenericArgsPack () {
266
+ SmallVector<Type, 2 > TypeAliasType::getExpandedGenericArgs () {
263
267
if (!getDecl ()->isGeneric ())
264
- return nullptr ;
268
+ return SmallVector<Type, 2 >() ;
265
269
266
270
auto genericSig = getGenericSignature ();
267
- return PackType::get ( getASTContext (),
271
+ return PackType::getExpandedGenericArgs (
268
272
genericSig.getInnermostGenericParams (),
269
273
getDirectGenericArgs ());
270
274
}
271
275
272
- // / <T...> Pack{T, Pack{Int, String}} => Pack {T..., Int, String}
273
- PackType * PackType::get ( const ASTContext &C,
274
- TypeArrayView<GenericTypeParamType> params,
275
- ArrayRef<Type> args) {
276
+ // / <T...> Pack{T, Pack{Int, String}} => {T..., Int, String}
277
+ SmallVector<Type, 2 >
278
+ PackType::getExpandedGenericArgs ( TypeArrayView<GenericTypeParamType> params,
279
+ ArrayRef<Type> args) {
276
280
SmallVector<Type, 2 > wrappedArgs;
277
281
278
282
assert (params.size () == args.size ());
@@ -288,7 +292,7 @@ PackType *PackType::get(const ASTContext &C,
288
292
wrappedArgs.push_back (arg);
289
293
}
290
294
291
- return get (C, wrappedArgs) ;
295
+ return wrappedArgs;
292
296
}
293
297
294
298
PackType *PackType::getSingletonPackExpansion (Type param) {
@@ -347,7 +351,7 @@ static CanPackType getApproximateFormalPackType(const ASTContext &ctx,
347
351
Collection loweredEltTypes) {
348
352
// Build an array of formal element types, but be lazy about it:
349
353
// use the original array unless we see an element type that doesn't
350
- // work as a legal format type.
354
+ // work as a legal formal type.
351
355
Optional<SmallVector<CanType, 4 >> formalEltTypes;
352
356
for (auto i : indices (loweredEltTypes)) {
353
357
auto loweredEltType = loweredEltTypes[i];
0 commit comments