Skip to content

Commit b1070f2

Browse files
committed
[CodeComplete] Avoid distinguishing between closure types
This seems to be redundant now that we no longer attempt to skip multi-statement closure bodies.
1 parent 562ab8a commit b1070f2

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

include/swift/Sema/CompletionContextFinder.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class CompletionContextFinder : public ASTWalker {
2828
enum class ContextKind {
2929
FallbackExpression,
3030
StringInterpolation,
31-
SingleStmtClosure,
32-
MultiStmtClosure,
31+
Closure,
3332
ErrorExpression
3433
};
3534

@@ -73,12 +72,6 @@ class CompletionContextFinder : public ASTWalker {
7372

7473
PostWalkResult<Expr *> walkToExprPost(Expr *E) override;
7574

76-
/// Check whether code completion expression is located inside of a
77-
/// multi-statement closure.
78-
bool locatedInMultiStmtClosure() const {
79-
return hasContext(ContextKind::MultiStmtClosure);
80-
}
81-
8275
bool locatedInStringInterpolation() const {
8376
return hasContext(ContextKind::StringInterpolation);
8477
}

lib/Sema/CompletionContextFinder.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ CompletionContextFinder::CompletionContextFinder(
2727

2828
ASTWalker::PreWalkResult<Expr *>
2929
CompletionContextFinder::walkToExprPre(Expr *E) {
30-
if (auto *closure = dyn_cast<ClosureExpr>(E)) {
31-
Contexts.push_back({closure->hasSingleExpressionBody()
32-
? ContextKind::SingleStmtClosure
33-
: ContextKind::MultiStmtClosure,
34-
closure});
35-
}
30+
if (auto *closure = dyn_cast<ClosureExpr>(E))
31+
Contexts.push_back({ContextKind::Closure, closure});
3632

3733
if (isa<InterpolatedStringLiteralExpr>(E)) {
3834
Contexts.push_back({ContextKind::StringInterpolation, E});
@@ -120,15 +116,12 @@ CompletionContextFinder::getFallbackCompletionExpr() const {
120116
fallback = Fallback{context.E, fallbackDC, separatePrecheck};
121117
continue;
122118

123-
case ContextKind::SingleStmtClosure:
119+
case ContextKind::Closure:
124120
if (!fallback && context.E != InitialExpr)
125121
fallback = Fallback{context.E, fallbackDC, separatePrecheck};
126122
fallbackDC = cast<AbstractClosureExpr>(context.E);
127123
continue;
128124

129-
case ContextKind::MultiStmtClosure:
130-
fallbackDC = cast<AbstractClosureExpr>(context.E);
131-
LLVM_FALLTHROUGH;
132125
case ContextKind::ErrorExpression:;
133126
fallback = llvm::None;
134127
separatePrecheck = true;

0 commit comments

Comments
 (0)