Skip to content

Commit f0b7f96

Browse files
authored
Merge pull request #23733 from slavapestov/prepare-to-be-removed
IDE: Remove prepareForRetypechecking()
2 parents 4dcea1c + 3095c36 commit f0b7f96

File tree

4 files changed

+0
-56
lines changed

4 files changed

+0
-56
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,8 +1304,6 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
13041304
return std::make_pair(ParsedExpr->getType(), refDecl);
13051305
}
13061306

1307-
prepareForRetypechecking(ParsedExpr);
1308-
13091307
ConcreteDeclRef ReferencedDecl = nullptr;
13101308
Expr *ModifiedExpr = ParsedExpr;
13111309
if (auto T = getTypeOfCompletionContextExpr(P.Context, CurDeclContext,
@@ -3340,7 +3338,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
33403338
if (expr->getType() && !expr->getType()->hasError())
33413339
return expr;
33423340

3343-
prepareForRetypechecking(expr);
33443341
if (!typeCheckExpression(const_cast<DeclContext *>(CurrDeclContext), expr))
33453342
return expr;
33463343
return LHS;

lib/IDE/ConformingMethodList.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ void ConformingMethodListCallbacks::doneParsing() {
7575

7676
// Type check the expression if needed.
7777
if (!T || T->is<ErrorType>()) {
78-
prepareForRetypechecking(ParsedExpr);
7978
ConcreteDeclRef ReferencedDecl = nullptr;
8079
auto optT = getTypeOfCompletionContextExpr(P.Context, CurDeclContext,
8180
CompletionTypeCheckKind::Normal,

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,53 +31,6 @@
3131
using namespace swift;
3232
using namespace ide;
3333

34-
//===----------------------------------------------------------------------===//
35-
// prepareForRetypechecking(Expr *)
36-
//===----------------------------------------------------------------------===//
37-
38-
/// Prepare the given expression for type-checking again, prinicipally by
39-
/// erasing any ErrorType types on the given expression, allowing later
40-
/// type-checking to make progress.
41-
///
42-
/// FIXME: this is fundamentally a workaround for the fact that we may end up
43-
/// typechecking parts of an expression more than once - first for checking
44-
/// the context, and later for checking more-specific things like unresolved
45-
/// members. We should restructure code-completion type-checking so that we
46-
/// never typecheck more than once (or find a more principled way to do it).
47-
void swift::ide::prepareForRetypechecking(Expr *E) {
48-
assert(E);
49-
struct Eraser : public ASTWalker {
50-
std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
51-
if (expr && expr->getType() && (expr->getType()->hasError() ||
52-
expr->getType()->hasUnresolvedType()))
53-
expr->setType(Type());
54-
if (auto *ACE = dyn_cast_or_null<AutoClosureExpr>(expr)) {
55-
return { true, ACE->getSingleExpressionBody() };
56-
}
57-
return { true, expr };
58-
}
59-
bool walkToTypeLocPre(TypeLoc &TL) override {
60-
if (TL.getType() && (TL.getType()->hasError() ||
61-
TL.getType()->hasUnresolvedType()))
62-
TL.setType(Type());
63-
return true;
64-
}
65-
66-
std::pair<bool, Pattern*> walkToPatternPre(Pattern *P) override {
67-
if (P && P->hasType() && (P->getType()->hasError() ||
68-
P->getType()->hasUnresolvedType())) {
69-
P->setType(Type());
70-
}
71-
return { true, P };
72-
}
73-
std::pair<bool, Stmt *> walkToStmtPre(Stmt *S) override {
74-
return { false, S };
75-
}
76-
};
77-
78-
E->walk(Eraser());
79-
}
80-
8134
//===----------------------------------------------------------------------===//
8235
// typeCheckContextUntil(DeclContext, SourceLoc)
8336
//===----------------------------------------------------------------------===//

lib/IDE/ExprContextAnalysis.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ class AnyFunctionType;
2525

2626
namespace ide {
2727

28-
/// Prepare the given expression for type-checking again, prinicipally by
29-
/// erasing any ErrorType types on the given expression, allowing later
30-
/// type-checking to make progress.
31-
void prepareForRetypechecking(Expr *E);
32-
3328
/// Type check parent contexts of the given decl context, and the body of the
3429
/// given context until \c Loc if the context is a function body.
3530
void typeCheckContextUntil(DeclContext *DC, SourceLoc Loc);

0 commit comments

Comments
 (0)