@@ -109,13 +109,11 @@ namespace {
109
109
// / FIXME: Remove this.
110
110
class SanitizeExpr : public ASTWalker {
111
111
ASTContext &C;
112
- bool ShouldReusePrecheckedType;
113
112
llvm::SmallDenseMap<OpaqueValueExpr *, Expr *, 4 > OpenExistentials;
114
113
115
114
public:
116
- SanitizeExpr (ASTContext &C,
117
- bool shouldReusePrecheckedType)
118
- : C(C), ShouldReusePrecheckedType(shouldReusePrecheckedType) { }
115
+ SanitizeExpr (ASTContext &C)
116
+ : C(C) { }
119
117
120
118
std::pair<bool , ArgumentList *>
121
119
walkToArgumentListPre (ArgumentList *argList) override {
@@ -126,12 +124,6 @@ class SanitizeExpr : public ASTWalker {
126
124
127
125
std::pair<bool , Expr *> walkToExprPre (Expr *expr) override {
128
126
while (true ) {
129
-
130
- // If we should reuse pre-checked types, don't sanitize the expression
131
- // if it's already type-checked.
132
- if (ShouldReusePrecheckedType && expr->getType ())
133
- return { false , expr };
134
-
135
127
// OpenExistentialExpr contains OpaqueValueExpr in its sub expression.
136
128
if (auto OOE = dyn_cast<OpenExistentialExpr>(expr)) {
137
129
auto archetypeVal = OOE->getOpaqueValue ();
@@ -301,8 +293,7 @@ getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,
301
293
FreeTypeVariableBinding allowFreeTypeVariables) {
302
294
auto &Context = dc->getASTContext ();
303
295
304
- expr = expr->walk (SanitizeExpr (Context,
305
- /* shouldReusePrecheckedType=*/ false ));
296
+ expr = expr->walk (SanitizeExpr (Context));
306
297
307
298
FrontendStatsTracer StatsTracer (Context.Stats ,
308
299
" typecheck-expr-no-apply" , expr);
@@ -400,8 +391,7 @@ getTypeOfCompletionOperatorImpl(DeclContext *DC, Expr *expr,
400
391
" typecheck-completion-operator" , expr);
401
392
PrettyStackTraceExpr stackTrace (Context, " type-checking" , expr);
402
393
403
- expr = expr->walk (SanitizeExpr (Context,
404
- /* shouldReusePrecheckedType=*/ false ));
394
+ expr = expr->walk (SanitizeExpr (Context));
405
395
406
396
ConstraintSystemOptions options;
407
397
options |= ConstraintSystemFlags::SuppressDiagnostics;
@@ -576,8 +566,7 @@ bool TypeChecker::typeCheckForCodeCompletion(
576
566
return false ;
577
567
578
568
if (auto *expr = getAsExpr (node)) {
579
- node = expr->walk (SanitizeExpr (Context,
580
- /* shouldReusePrecheckedType=*/ false ));
569
+ node = expr->walk (SanitizeExpr (Context));
581
570
}
582
571
583
572
CompletionContextFinder contextAnalyzer (node, DC);
@@ -773,7 +762,7 @@ swift::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
773
762
bool swift::typeCheckExpression (DeclContext *DC, Expr *&parsedExpr) {
774
763
auto &ctx = DC->getASTContext ();
775
764
776
- parsedExpr = parsedExpr->walk (SanitizeExpr (ctx, /* shouldReusePrecheckedType= */ false ));
765
+ parsedExpr = parsedExpr->walk (SanitizeExpr (ctx));
777
766
778
767
DiagnosticSuppression suppression (ctx.Diags );
779
768
auto resultTy = TypeChecker::typeCheckExpression (
0 commit comments