@@ -4447,8 +4447,8 @@ static bool generateInitPatternConstraints(ConstraintSystem &cs,
44474447 return false ;
44484448}
44494449
4450- // / Generate constraints for a for-in statement preamble, expecting a
4451- // / `PackExpansionExpr`.
4450+ // / Generate constraints for a for-in statement preamble where the expression
4451+ // / is a `PackExpansionExpr`.
44524452static llvm::Optional<PackIterationInfo>
44534453generateForEachStmtConstraints (ConstraintSystem &cs, DeclContext *dc,
44544454 PackExpansionExpr *expansion, Type patternType) {
@@ -4524,6 +4524,7 @@ generateForEachStmtConstraints(ConstraintSystem &cs, DeclContext *dc,
45244524
45254525 auto *makeIteratorCall =
45264526 CallExpr::createImplicitEmpty (ctx, makeIteratorRef);
4527+
45274528 Pattern *pattern = NamedPattern::createImplicit (ctx, makeIteratorVar);
45284529 auto *PB = PatternBindingDecl::createImplicit (
45294530 ctx, StaticSpellingKind::None, pattern, makeIteratorCall, dc);
@@ -4540,6 +4541,7 @@ generateForEachStmtConstraints(ConstraintSystem &cs, DeclContext *dc,
45404541 return llvm::None;
45414542
45424543 sequenceIterationInfo.makeIteratorVar = PB;
4544+
45434545 // Type of sequence expression has to conform to Sequence protocol.
45444546 //
45454547 // Note that the following emulates having `$generator` separately
@@ -4606,7 +4608,7 @@ generateForEachStmtConstraints(ConstraintSystem &cs, DeclContext *dc,
46064608 cs.setTargetFor (sequenceIterationInfo.nextCall , nextTarget);
46074609 }
46084610
4609- // Generate constraints for the pattern
4611+ // Generate constraints for the pattern.
46104612 Type initType =
46114613 cs.generateConstraints (typeCheckedPattern, elementLocator,
46124614 shouldBindPatternVarsOneWay, nullptr , 0 );
@@ -4677,7 +4679,7 @@ generateForEachStmtConstraints(ConstraintSystem &cs,
46774679 if (isa<PackExpansionExpr>(forEachExpr)) {
46784680 auto *expansion = cast<PackExpansionExpr>(forEachExpr);
46794681
4680- // Generate constraints for the pattern
4682+ // Generate constraints for the pattern.
46814683 Type patternType = cs.generateConstraints (
46824684 pattern, elementLocator, target.shouldBindPatternVarsOneWay (), nullptr ,
46834685 0 );
0 commit comments