File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -469,6 +469,8 @@ class SyntacticElementTarget {
469
469
bool shouldBindPatternVarsOneWay () const {
470
470
if (kind == Kind::expression)
471
471
return expression.bindPatternVarsOneWay ;
472
+ if (kind == Kind::forEachStmt)
473
+ return !ignoreForEachWhereClause () && forEachStmt.stmt ->getWhere ();
472
474
return false ;
473
475
}
474
476
Original file line number Diff line number Diff line change @@ -295,3 +295,24 @@ do {
295
295
}
296
296
}
297
297
}
298
+
299
+ // rdar://117220710 - The compiler incorrectly infers `v` pattern to be optional.
300
+ do {
301
+ struct S {
302
+ var test : Int
303
+ }
304
+
305
+ func check( _: S ? , _: S ? ) -> Bool { false }
306
+
307
+ func test( data: [ S ] ? , exclusion: S ? ) {
308
+ for v in data ?? [ ] where check ( v, exclusion) {
309
+ _ = v. test // Ok
310
+ }
311
+ }
312
+
313
+ let _ = { ( data: [ S ] ? , exclusion: S ? ) in
314
+ for v in data ?? [ ] where check ( v, exclusion) {
315
+ _ = v. test // Ok
316
+ }
317
+ }
318
+ }
You can’t perform that action at this time.
0 commit comments