Skip to content

Commit b0307a5

Browse files
committed
[CodeCompletion] Remove shouldReusePrecheckedType from SanitizeExpr.
1 parent 38d8158 commit b0307a5

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

lib/Sema/TypeCheckCodeCompletion.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ namespace {
109109
/// FIXME: Remove this.
110110
class SanitizeExpr : public ASTWalker {
111111
ASTContext &C;
112-
bool ShouldReusePrecheckedType;
113112
llvm::SmallDenseMap<OpaqueValueExpr *, Expr *, 4> OpenExistentials;
114113

115114
public:
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,
773762
bool 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

Comments
 (0)