@@ -408,6 +408,9 @@ namespace {
408
408
// / Rewrites an expression by applying the solution of a constraint
409
409
// / system to that expression.
410
410
class ExprRewriter : public ExprVisitor <ExprRewriter, Expr *> {
411
+ // Delayed items to type-check.
412
+ SmallVector<Decl *, 4 > LocalDeclsToTypeCheck;
413
+
411
414
public:
412
415
ConstraintSystem &cs;
413
416
DeclContext *dc;
@@ -424,6 +427,10 @@ namespace {
424
427
425
428
ConstraintSystem &getConstraintSystem () const { return cs; }
426
429
430
+ void addLocalDeclToTypeCheck (Decl *D) {
431
+ LocalDeclsToTypeCheck.push_back (D);
432
+ }
433
+
427
434
// / Coerce the given tuple to another tuple type.
428
435
// /
429
436
// / \param expr The expression we're converting.
@@ -5604,6 +5611,10 @@ namespace {
5604
5611
diag::add_consume_to_silence)
5605
5612
.fixItInsert (coercion->getStartLoc (), " consume " );
5606
5613
}
5614
+
5615
+ // Type-check any local decls encountered.
5616
+ for (auto *D : LocalDeclsToTypeCheck)
5617
+ TypeChecker::typeCheckDecl (D);
5607
5618
}
5608
5619
5609
5620
// / Diagnose an optional injection that is probably not what the
@@ -8805,22 +8816,15 @@ namespace {
8805
8816
8806
8817
class ExprWalker : public ASTWalker , public SyntacticElementTargetRewriter {
8807
8818
ExprRewriter &Rewriter;
8808
- SmallVector<Decl *, 4 > LocalDeclsToTypeCheck;
8809
8819
8810
8820
public:
8811
8821
ExprWalker (ExprRewriter &Rewriter) : Rewriter(Rewriter) { }
8812
8822
8813
- ~ExprWalker () {
8814
- // Type-check any local decls encountered.
8815
- for (auto *D : LocalDeclsToTypeCheck)
8816
- TypeChecker::typeCheckDecl (D);
8817
- }
8818
-
8819
8823
Solution &getSolution () const override { return Rewriter.solution ; }
8820
8824
DeclContext *&getCurrentDC () const override { return Rewriter.dc ; }
8821
8825
8822
8826
void addLocalDeclToTypeCheck (Decl *D) override {
8823
- LocalDeclsToTypeCheck. push_back (D);
8827
+ Rewriter. addLocalDeclToTypeCheck (D);
8824
8828
}
8825
8829
8826
8830
bool shouldWalkIntoPropertyWrapperPlaceholderValue () override {
0 commit comments