@@ -114,10 +114,6 @@ class SyntacticElementTarget {
114
114
// / Whether the expression result will be discarded at the end.
115
115
bool isDiscarded;
116
116
117
- // / Whether to bind the variables encountered within the pattern to
118
- // / fresh type variables via one-way constraints.
119
- bool bindPatternVarsOneWay;
120
-
121
117
union {
122
118
struct {
123
119
// / The pattern binding declaration for an initialization, if any.
@@ -165,10 +161,9 @@ class SyntacticElementTarget {
165
161
ForEachStmt *stmt;
166
162
DeclContext *dc;
167
163
Pattern *pattern;
168
- bool ignoreWhereClause;
169
164
GenericEnvironment *packElementEnv;
170
165
ForEachStmtInfo info;
171
- } forEachStmt ;
166
+ } forEachPreamble ;
172
167
173
168
PatternBindingDecl *patternBinding;
174
169
};
@@ -246,35 +241,33 @@ class SyntacticElementTarget {
246
241
}
247
242
248
243
SyntacticElementTarget (ForEachStmt *stmt, DeclContext *dc,
249
- bool ignoreWhereClause,
250
244
GenericEnvironment *packElementEnv)
251
245
: 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;
256
249
}
257
250
258
251
// / Form a target for the initialization of a pattern from an expression.
259
252
static SyntacticElementTarget
260
253
forInitialization (Expr *initializer, DeclContext *dc, Type patternType,
261
- Pattern *pattern, bool bindPatternVarsOneWay );
254
+ Pattern *pattern);
262
255
263
256
// / Form a target for the initialization of a pattern binding entry from
264
257
// / an expression.
265
258
static SyntacticElementTarget
266
259
forInitialization (Expr *initializer, Type patternType,
267
260
PatternBindingDecl *patternBinding,
268
- unsigned patternBindingIndex, bool bindPatternVarsOneWay );
261
+ unsigned patternBindingIndex);
269
262
270
263
// / Form an expression target for a ReturnStmt.
271
264
static SyntacticElementTarget
272
265
forReturn (ReturnStmt *returnStmt, Type contextTy, DeclContext *dc);
273
266
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.
275
269
static SyntacticElementTarget
276
270
forForEachPreamble (ForEachStmt *stmt, DeclContext *dc,
277
- bool ignoreWhereClause = false ,
278
271
GenericEnvironment *packElementEnv = nullptr );
279
272
280
273
// / Form a target for a property with an attached property wrapper that is
@@ -376,7 +369,7 @@ class SyntacticElementTarget {
376
369
}
377
370
378
371
case Kind::forEachPreamble:
379
- return forEachStmt .dc ;
372
+ return forEachPreamble .dc ;
380
373
}
381
374
llvm_unreachable (" invalid decl context type" );
382
375
}
@@ -500,16 +493,6 @@ class SyntacticElementTarget {
500
493
return false ;
501
494
}
502
495
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
-
513
496
// / Whether or not an opaque value placeholder should be injected into the
514
497
// / first \c wrappedValue argument of an apply expression so the initializer
515
498
// / expression can be turned into a property wrapper generator function.
@@ -555,24 +538,19 @@ class SyntacticElementTarget {
555
538
return expression.initialization .patternBindingIndex ;
556
539
}
557
540
558
- bool ignoreForEachWhereClause () const {
559
- assert (isForEachPreamble ());
560
- return forEachStmt.ignoreWhereClause ;
561
- }
562
-
563
541
GenericEnvironment *getPackElementEnv () const {
564
542
assert (isForEachPreamble ());
565
- return forEachStmt .packElementEnv ;
543
+ return forEachPreamble .packElementEnv ;
566
544
}
567
545
568
546
const ForEachStmtInfo &getForEachStmtInfo () const {
569
547
assert (isForEachPreamble ());
570
- return forEachStmt .info ;
548
+ return forEachPreamble .info ;
571
549
}
572
550
573
551
ForEachStmtInfo &getForEachStmtInfo () {
574
552
assert (isForEachPreamble ());
575
- return forEachStmt .info ;
553
+ return forEachPreamble .info ;
576
554
}
577
555
578
556
// / Whether this context infers an opaque return type.
@@ -599,7 +577,7 @@ class SyntacticElementTarget {
599
577
return getInitializationPattern ();
600
578
601
579
if (kind == Kind::forEachPreamble)
602
- return forEachStmt .pattern ;
580
+ return forEachPreamble .pattern ;
603
581
604
582
return nullptr ;
605
583
}
@@ -612,7 +590,7 @@ class SyntacticElementTarget {
612
590
}
613
591
614
592
if (kind == Kind::forEachPreamble) {
615
- forEachStmt .pattern = pattern;
593
+ forEachPreamble .pattern = pattern;
616
594
return ;
617
595
}
618
596
@@ -743,7 +721,7 @@ class SyntacticElementTarget {
743
721
return nullptr ;
744
722
745
723
case Kind::forEachPreamble:
746
- return forEachStmt .stmt ;
724
+ return forEachPreamble .stmt ;
747
725
}
748
726
llvm_unreachable (" invalid case label type" );
749
727
}
@@ -855,7 +833,7 @@ class SyntacticElementTarget {
855
833
856
834
// For-in preamble target doesn't cover the body.
857
835
case Kind::forEachPreamble:
858
- auto *stmt = forEachStmt .stmt ;
836
+ auto *stmt = forEachPreamble .stmt ;
859
837
SourceLoc startLoc = stmt->getForLoc ();
860
838
SourceLoc endLoc = stmt->getParsedSequence ()->getEndLoc ();
861
839
@@ -898,7 +876,7 @@ class SyntacticElementTarget {
898
876
}
899
877
900
878
case Kind::forEachPreamble:
901
- return forEachStmt .stmt ->getStartLoc ();
879
+ return forEachPreamble .stmt ->getStartLoc ();
902
880
}
903
881
llvm_unreachable (" invalid target type" );
904
882
}
0 commit comments