Skip to content

Commit 41ce264

Browse files
committed
[RequirementMachine] Simplify same-shape requirement inference from pack
expansion types by equating the pack expansion count/shape type with each shape of the referenced packs in the expansion.
1 parent 38a2c82 commit 41ce264

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/AST/RequirementMachine/RequirementLowering.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,10 @@ struct InferRequirementsWalker : public TypeWalker {
500500
SmallVector<Type, 2> packReferences;
501501
packExpansion->getPatternType()->getTypeSequenceParameters(packReferences);
502502

503-
if (packReferences.size() > 1) {
504-
auto first = packReferences.begin();
505-
auto second = first + 1;
506-
while (second != packReferences.end()) {
507-
Requirement req(RequirementKind::SameShape, *first++, *second++);
508-
desugarRequirement(req, SourceLoc(), reqs, errors);
509-
}
503+
auto countType = packExpansion->getCountType();
504+
for (auto pack : packReferences) {
505+
Requirement req(RequirementKind::SameShape, countType, pack);
506+
desugarRequirement(req, SourceLoc(), reqs, errors);
510507
}
511508
}
512509

0 commit comments

Comments
 (0)