@@ -39,8 +39,7 @@ struct PackTypeParameterCollector: TypeWalker {
39
39
if (paramTy->isParameterPack ())
40
40
typeParams.insert (paramTy);
41
41
} else if (auto *archetypeTy = t->getAs <PackArchetypeType>()) {
42
- if (archetypeTy->isRoot ())
43
- typeParams.insert (paramTy);
42
+ typeParams.insert (archetypeTy->getRoot ());
44
43
}
45
44
46
45
return Action::Continue;
@@ -314,35 +313,20 @@ CanPackType PackType::getReducedShape() {
314
313
}
315
314
316
315
CanType TypeBase::getReducedShape () {
316
+ if (auto *packArchetype = getAs<PackArchetypeType>())
317
+ return packArchetype->getReducedShape ();
318
+
317
319
if (auto *packType = getAs<PackType>())
318
320
return packType->getReducedShape ();
319
321
320
322
if (auto *expansionType = getAs<PackExpansionType>())
321
323
return expansionType->getReducedShape ();
322
324
323
- struct PatternTypeWalker : public TypeWalker {
324
- CanType shapeType;
325
-
326
- Action walkToTypePre (Type type) override {
327
- // Don't consider pack references inside nested pack
328
- // expansion types.
329
- if (type->is <PackExpansionType>()) {
330
- return Action::Stop;
331
- }
332
-
333
- if (auto *archetype = type->getAs <PackArchetypeType>()) {
334
- shapeType = archetype->getReducedShape ();
335
- return Action::Stop;
336
- }
337
-
338
- return Action::Continue;
339
- }
340
- } patternTypeWalker;
341
-
342
- Type (this ).walk (patternTypeWalker);
325
+ SmallVector<Type, 2 > rootParameterPacks;
326
+ getTypeParameterPacks (rootParameterPacks);
343
327
344
- if (patternTypeWalker. shapeType )
345
- return patternTypeWalker. shapeType ;
328
+ if (!rootParameterPacks. empty () )
329
+ return rootParameterPacks. front ()-> getReducedShape () ;
346
330
347
331
assert (!isTypeVariableOrMember ());
348
332
assert (!hasTypeParameter ());
0 commit comments