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 {
469469 bool shouldBindPatternVarsOneWay () const {
470470 if (kind == Kind::expression)
471471 return expression.bindPatternVarsOneWay ;
472+ if (kind == Kind::forEachStmt)
473+ return !ignoreForEachWhereClause () && forEachStmt.stmt ->getWhere ();
472474 return false ;
473475 }
474476
Original file line number Diff line number Diff line change @@ -295,3 +295,24 @@ do {
295295 }
296296 }
297297}
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