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 @@ -1208,6 +1208,17 @@ class SyntacticElementSolutionApplication
1208
1208
return nullptr ;
1209
1209
}
1210
1210
1211
+ ASTNode visit (Stmt *S) {
1212
+ auto rewritten = ASTVisitor::visit (S);
1213
+ if (!rewritten)
1214
+ return {};
1215
+
1216
+ if (auto *stmt = getAsStmt (rewritten))
1217
+ performStmtDiagnostics (stmt, context.getAsDeclContext ());
1218
+
1219
+ return rewritten;
1220
+ }
1221
+
1211
1222
void visitDecl (Decl *decl) {
1212
1223
if (isa<IfConfigDecl>(decl))
1213
1224
return ;
Original file line number Diff line number Diff line change @@ -405,6 +405,36 @@ func test_type_finder_doesnt_walk_into_inner_closures() {
405
405
}
406
406
}
407
407
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
+
408
438
// rdar://93796211 (issue#59035) - crash during solution application to fallthrough statement
409
439
func test_fallthrough_stmt( ) {
410
440
{
You can’t perform that action at this time.
0 commit comments