@@ -109,13 +109,11 @@ namespace {
109109// / FIXME: Remove this.
110110class SanitizeExpr : public ASTWalker {
111111 ASTContext &C;
112- bool ShouldReusePrecheckedType;
113112 llvm::SmallDenseMap<OpaqueValueExpr *, Expr *, 4 > OpenExistentials;
114113
115114public:
116- SanitizeExpr (ASTContext &C,
117- bool shouldReusePrecheckedType)
118- : C(C), ShouldReusePrecheckedType(shouldReusePrecheckedType) { }
115+ SanitizeExpr (ASTContext &C)
116+ : C(C) { }
119117
120118 std::pair<bool , ArgumentList *>
121119 walkToArgumentListPre (ArgumentList *argList) override {
@@ -126,12 +124,6 @@ class SanitizeExpr : public ASTWalker {
126124
127125 std::pair<bool , Expr *> walkToExprPre (Expr *expr) override {
128126 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-
135127 // OpenExistentialExpr contains OpaqueValueExpr in its sub expression.
136128 if (auto OOE = dyn_cast<OpenExistentialExpr>(expr)) {
137129 auto archetypeVal = OOE->getOpaqueValue ();
@@ -301,8 +293,7 @@ getTypeOfExpressionWithoutApplying(Expr *&expr, DeclContext *dc,
301293 FreeTypeVariableBinding allowFreeTypeVariables) {
302294 auto &Context = dc->getASTContext ();
303295
304- expr = expr->walk (SanitizeExpr (Context,
305- /* shouldReusePrecheckedType=*/ false ));
296+ expr = expr->walk (SanitizeExpr (Context));
306297
307298 FrontendStatsTracer StatsTracer (Context.Stats ,
308299 " typecheck-expr-no-apply" , expr);
@@ -400,8 +391,7 @@ getTypeOfCompletionOperatorImpl(DeclContext *DC, Expr *expr,
400391 " typecheck-completion-operator" , expr);
401392 PrettyStackTraceExpr stackTrace (Context, " type-checking" , expr);
402393
403- expr = expr->walk (SanitizeExpr (Context,
404- /* shouldReusePrecheckedType=*/ false ));
394+ expr = expr->walk (SanitizeExpr (Context));
405395
406396 ConstraintSystemOptions options;
407397 options |= ConstraintSystemFlags::SuppressDiagnostics;
@@ -576,8 +566,7 @@ bool TypeChecker::typeCheckForCodeCompletion(
576566 return false ;
577567
578568 if (auto *expr = getAsExpr (node)) {
579- node = expr->walk (SanitizeExpr (Context,
580- /* shouldReusePrecheckedType=*/ false ));
569+ node = expr->walk (SanitizeExpr (Context));
581570 }
582571
583572 CompletionContextFinder contextAnalyzer (node, DC);
@@ -773,7 +762,7 @@ swift::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
773762bool swift::typeCheckExpression (DeclContext *DC, Expr *&parsedExpr) {
774763 auto &ctx = DC->getASTContext ();
775764
776- parsedExpr = parsedExpr->walk (SanitizeExpr (ctx, /* shouldReusePrecheckedType= */ false ));
765+ parsedExpr = parsedExpr->walk (SanitizeExpr (ctx));
777766
778767 DiagnosticSuppression suppression (ctx.Diags );
779768 auto resultTy = TypeChecker::typeCheckExpression (
0 commit comments