@@ -114,10 +114,6 @@ class SyntacticElementTarget {
114114 // / Whether the expression result will be discarded at the end.
115115 bool isDiscarded;
116116
117- // / Whether to bind the variables encountered within the pattern to
118- // / fresh type variables via one-way constraints.
119- bool bindPatternVarsOneWay;
120-
121117 union {
122118 struct {
123119 // / The pattern binding declaration for an initialization, if any.
@@ -165,10 +161,9 @@ class SyntacticElementTarget {
165161 ForEachStmt *stmt;
166162 DeclContext *dc;
167163 Pattern *pattern;
168- bool ignoreWhereClause;
169164 GenericEnvironment *packElementEnv;
170165 ForEachStmtInfo info;
171- } forEachStmt ;
166+ } forEachPreamble ;
172167
173168 PatternBindingDecl *patternBinding;
174169 };
@@ -246,35 +241,33 @@ class SyntacticElementTarget {
246241 }
247242
248243 SyntacticElementTarget (ForEachStmt *stmt, DeclContext *dc,
249- bool ignoreWhereClause,
250244 GenericEnvironment *packElementEnv)
251245 : kind(Kind::forEachPreamble) {
252- forEachStmt.stmt = stmt;
253- forEachStmt.dc = dc;
254- forEachStmt.ignoreWhereClause = ignoreWhereClause;
255- forEachStmt.packElementEnv = packElementEnv;
246+ forEachPreamble.stmt = stmt;
247+ forEachPreamble.dc = dc;
248+ forEachPreamble.packElementEnv = packElementEnv;
256249 }
257250
258251 // / Form a target for the initialization of a pattern from an expression.
259252 static SyntacticElementTarget
260253 forInitialization (Expr *initializer, DeclContext *dc, Type patternType,
261- Pattern *pattern, bool bindPatternVarsOneWay );
254+ Pattern *pattern);
262255
263256 // / Form a target for the initialization of a pattern binding entry from
264257 // / an expression.
265258 static SyntacticElementTarget
266259 forInitialization (Expr *initializer, Type patternType,
267260 PatternBindingDecl *patternBinding,
268- unsigned patternBindingIndex, bool bindPatternVarsOneWay );
261+ unsigned patternBindingIndex);
269262
270263 // / Form an expression target for a ReturnStmt.
271264 static SyntacticElementTarget
272265 forReturn (ReturnStmt *returnStmt, Type contextTy, DeclContext *dc);
273266
274- // / Form a target for the preamble of a for-in loop, excluding its body.
267+ // / Form a target for the preamble of a for-in loop, excluding its where
268+ // / clause and body.
275269 static SyntacticElementTarget
276270 forForEachPreamble (ForEachStmt *stmt, DeclContext *dc,
277- bool ignoreWhereClause = false ,
278271 GenericEnvironment *packElementEnv = nullptr );
279272
280273 // / Form a target for a property with an attached property wrapper that is
@@ -376,7 +369,7 @@ class SyntacticElementTarget {
376369 }
377370
378371 case Kind::forEachPreamble:
379- return forEachStmt .dc ;
372+ return forEachPreamble .dc ;
380373 }
381374 llvm_unreachable (" invalid decl context type" );
382375 }
@@ -500,16 +493,6 @@ class SyntacticElementTarget {
500493 return false ;
501494 }
502495
503- // / Whether to bind the types of any variables within the pattern via
504- // / one-way constraints.
505- bool shouldBindPatternVarsOneWay () const {
506- if (kind == Kind::expression)
507- return expression.bindPatternVarsOneWay ;
508- if (kind == Kind::forEachPreamble)
509- return !ignoreForEachWhereClause () && forEachStmt.stmt ->getWhere ();
510- return false ;
511- }
512-
513496 // / Whether or not an opaque value placeholder should be injected into the
514497 // / first \c wrappedValue argument of an apply expression so the initializer
515498 // / expression can be turned into a property wrapper generator function.
@@ -555,24 +538,19 @@ class SyntacticElementTarget {
555538 return expression.initialization .patternBindingIndex ;
556539 }
557540
558- bool ignoreForEachWhereClause () const {
559- assert (isForEachPreamble ());
560- return forEachStmt.ignoreWhereClause ;
561- }
562-
563541 GenericEnvironment *getPackElementEnv () const {
564542 assert (isForEachPreamble ());
565- return forEachStmt .packElementEnv ;
543+ return forEachPreamble .packElementEnv ;
566544 }
567545
568546 const ForEachStmtInfo &getForEachStmtInfo () const {
569547 assert (isForEachPreamble ());
570- return forEachStmt .info ;
548+ return forEachPreamble .info ;
571549 }
572550
573551 ForEachStmtInfo &getForEachStmtInfo () {
574552 assert (isForEachPreamble ());
575- return forEachStmt .info ;
553+ return forEachPreamble .info ;
576554 }
577555
578556 // / Whether this context infers an opaque return type.
@@ -599,7 +577,7 @@ class SyntacticElementTarget {
599577 return getInitializationPattern ();
600578
601579 if (kind == Kind::forEachPreamble)
602- return forEachStmt .pattern ;
580+ return forEachPreamble .pattern ;
603581
604582 return nullptr ;
605583 }
@@ -612,7 +590,7 @@ class SyntacticElementTarget {
612590 }
613591
614592 if (kind == Kind::forEachPreamble) {
615- forEachStmt .pattern = pattern;
593+ forEachPreamble .pattern = pattern;
616594 return ;
617595 }
618596
@@ -743,7 +721,7 @@ class SyntacticElementTarget {
743721 return nullptr ;
744722
745723 case Kind::forEachPreamble:
746- return forEachStmt .stmt ;
724+ return forEachPreamble .stmt ;
747725 }
748726 llvm_unreachable (" invalid case label type" );
749727 }
@@ -855,7 +833,7 @@ class SyntacticElementTarget {
855833
856834 // For-in preamble target doesn't cover the body.
857835 case Kind::forEachPreamble:
858- auto *stmt = forEachStmt .stmt ;
836+ auto *stmt = forEachPreamble .stmt ;
859837 SourceLoc startLoc = stmt->getForLoc ();
860838 SourceLoc endLoc = stmt->getParsedSequence ()->getEndLoc ();
861839
@@ -898,7 +876,7 @@ class SyntacticElementTarget {
898876 }
899877
900878 case Kind::forEachPreamble:
901- return forEachStmt .stmt ->getStartLoc ();
879+ return forEachPreamble .stmt ->getStartLoc ();
902880 }
903881 llvm_unreachable (" invalid target type" );
904882 }
0 commit comments