@@ -193,6 +193,22 @@ class ClosureConstraintGenerator
193
193
cs.setSolutionApplicationTarget (throwStmt, target);
194
194
}
195
195
196
+ void visitPoundAssertStmt (PoundAssertStmt *poundAssertStmt) {
197
+ auto *boolDecl = cs.getASTContext ().getBoolDecl ();
198
+ if (!boolDecl) {
199
+ hadError = true ;
200
+ return ;
201
+ }
202
+
203
+ SolutionApplicationTarget target (
204
+ poundAssertStmt->getCondition (), closure, CTP_Condition,
205
+ boolDecl->getDeclaredInterfaceType (), /* isDiscarded=*/ false );
206
+ if (cs.generateConstraints (target, FreeTypeVariableBinding::Disallow))
207
+ hadError = true ;
208
+
209
+ cs.setSolutionApplicationTarget (poundAssertStmt, target);
210
+ }
211
+
196
212
#define UNSUPPORTED_STMT (STMT ) void visit##STMT##Stmt(STMT##Stmt *) { \
197
213
llvm_unreachable (" Unsupported statement kind " #STMT); \
198
214
}
@@ -202,7 +218,6 @@ class ClosureConstraintGenerator
202
218
UNSUPPORTED_STMT (Case)
203
219
UNSUPPORTED_STMT (Fallthrough)
204
220
UNSUPPORTED_STMT (Fail)
205
- UNSUPPORTED_STMT (PoundAssert)
206
221
#undef UNSUPPORTED_STMT
207
222
};
208
223
@@ -467,7 +482,7 @@ class ClosureConstraintApplication
467
482
}
468
483
469
484
ASTNode visitThrowStmt (ThrowStmt *throwStmt) {
470
- // Rewrite the condition .
485
+ // Rewrite the error .
471
486
auto target = *solution.getConstraintSystem ()
472
487
.getSolutionApplicationTarget (throwStmt);
473
488
if (auto result = rewriteTarget (target))
@@ -477,6 +492,17 @@ class ClosureConstraintApplication
477
492
return throwStmt;
478
493
}
479
494
495
+ ASTNode visitPoundAssertStmt (PoundAssertStmt *poundAssertStmt) {
496
+ // Rewrite the condition.
497
+ auto target = *solution.getConstraintSystem ()
498
+ .getSolutionApplicationTarget (poundAssertStmt);
499
+ if (auto result = rewriteTarget (target))
500
+ poundAssertStmt->setCondition (result->getAsExpr ());
501
+ else
502
+ hadError = true ;
503
+ return poundAssertStmt;
504
+ }
505
+
480
506
#define UNSUPPORTED_STMT (STMT ) ASTNode visit##STMT##Stmt(STMT##Stmt *) { \
481
507
llvm_unreachable (" Unsupported statement kind " #STMT); \
482
508
}
@@ -486,7 +512,6 @@ class ClosureConstraintApplication
486
512
UNSUPPORTED_STMT(Case)
487
513
UNSUPPORTED_STMT(Fallthrough)
488
514
UNSUPPORTED_STMT(Fail)
489
- UNSUPPORTED_STMT(PoundAssert)
490
515
#undef UNSUPPORTED_STMT
491
516
492
517
};
0 commit comments