Skip to content

Commit 69d8398

Browse files
authored
Merge pull request #33270 from rintaro/ide-completion-typecheckcontextat
[CodeCompletion] Cleanup typeCheckContextAt()
2 parents f97d68f + ec8637c commit 69d8398

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ using namespace ide;
4242
// typeCheckContextAt(DeclContext, SourceLoc)
4343
//===----------------------------------------------------------------------===//
4444

45-
namespace {
46-
void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
47-
// Nothing to type check in module context.
48-
if (DC->isModuleScopeContext())
49-
return;
45+
void swift::ide::typeCheckContextAt(DeclContext *DC, SourceLoc Loc) {
46+
while (isa<AbstractClosureExpr>(DC))
47+
DC = DC->getParent();
5048

5149
// Make sure the extension has been bound, in case it is in an inactive #if
5250
// or something weird like that.
@@ -67,6 +65,7 @@ void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
6765
switch (DC->getContextKind()) {
6866
case DeclContextKind::AbstractClosureExpr:
6967
case DeclContextKind::Module:
68+
case DeclContextKind::FileUnit:
7069
case DeclContextKind::SerializedLocal:
7170
case DeclContextKind::EnumElementDecl:
7271
case DeclContextKind::GenericTypeDecl:
@@ -105,19 +104,8 @@ void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
105104
}
106105
break;
107106
}
108-
109-
case DeclContextKind::FileUnit:
110-
llvm_unreachable("module scope context handled above");
111107
}
112108
}
113-
} // anonymous namespace
114-
115-
void swift::ide::typeCheckContextAt(DeclContext *DC, SourceLoc Loc) {
116-
while (isa<AbstractClosureExpr>(DC))
117-
DC = DC->getParent();
118-
119-
typeCheckContextImpl(DC, Loc);
120-
}
121109

122110
//===----------------------------------------------------------------------===//
123111
// findParsedExpr(DeclContext, Expr)

0 commit comments

Comments
 (0)