File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1196,6 +1196,17 @@ class ClosureConstraintApplication
11961196 return nullptr ;
11971197 }
11981198
1199+ ASTNode visit (Stmt *S) {
1200+ auto rewritten = ASTVisitor::visit (S);
1201+ if (!rewritten)
1202+ return {};
1203+
1204+ if (auto *stmt = getAsStmt (rewritten))
1205+ performStmtDiagnostics (stmt, closure);
1206+
1207+ return rewritten;
1208+ }
1209+
11991210 void visitDecl (Decl *decl) {
12001211 if (isa<IfConfigDecl>(decl))
12011212 return ;
Original file line number Diff line number Diff line change @@ -405,6 +405,36 @@ func test_type_finder_doesnt_walk_into_inner_closures() {
405405 }
406406}
407407
408+ // rdar://94049113 - compiler accepts non-optional `guard let` in a closure
409+ func test_non_optional_guard_let_is_diagnosed( ) {
410+ func fn( _: ( Int ) -> Void ) { }
411+
412+ fn {
413+ if true {
414+ guard let v = $0 else { // expected-error {{initializer for conditional binding must have Optional type, not 'Int'}}
415+ return
416+ }
417+
418+ print ( v)
419+ }
420+ }
421+
422+ fn {
423+ switch $0 {
424+ case ( let val) :
425+ fn {
426+ guard let x = val else { // expected-error {{initializer for conditional binding must have Optional type, not 'Int'}}
427+ return
428+ }
429+
430+ print ( $0 + x)
431+ }
432+
433+ default : break
434+ }
435+ }
436+ }
437+
408438// rdar://93796211 (issue#59035) - crash during solution application to fallthrough statement
409439func test_fallthrough_stmt( ) {
410440 {
You can’t perform that action at this time.
0 commit comments