File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1246,6 +1246,18 @@ class ClosureConstraintApplication
1246
1246
ASTNode visitBraceStmt (BraceStmt *braceStmt) {
1247
1247
auto &cs = solution.getConstraintSystem ();
1248
1248
1249
+ // Diagnose defer statement being last one in block.
1250
+ if (!braceStmt->empty ()) {
1251
+ if (auto stmt = braceStmt->getLastElement ().dyn_cast <Stmt *>()) {
1252
+ if (auto deferStmt = dyn_cast<DeferStmt>(stmt)) {
1253
+ auto &diags = closure->getASTContext ().Diags ;
1254
+ diags
1255
+ .diagnose (deferStmt->getStartLoc (), diag::defer_stmt_at_block_end)
1256
+ .fixItReplace (deferStmt->getStartLoc (), " do" );
1257
+ }
1258
+ }
1259
+ }
1260
+
1249
1261
for (auto &node : braceStmt->getElements ()) {
1250
1262
if (auto expr = node.dyn_cast <Expr *>()) {
1251
1263
// Rewrite the expression.
You can’t perform that action at this time.
0 commit comments