Skip to content

Commit 3a82241

Browse files
committed
[IDE] Remove undoSingleExpressionReturn
Now that we do the transform in Sema, this is redundant.
1 parent 088307f commit 3a82241

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,39 +1609,6 @@ void CodeCompletionCallbacksImpl::afterPoundCompletion(SourceLoc CompletionLoc,
16091609
Consumer.handleResults(CompletionContext);
16101610
}
16111611

1612-
// Undoes the single-expression closure/function body transformation on the
1613-
// given DeclContext and its parent contexts if they have a single expression
1614-
// body that contains the code completion location.
1615-
//
1616-
// FIXME: Remove this once all expression position completions are migrated
1617-
// to work via TypeCheckCompletionCallback.
1618-
static void undoSingleExpressionReturn(DeclContext *DC) {
1619-
auto updateBody = [](BraceStmt *BS, ASTContext &Ctx) -> bool {
1620-
ASTNode LastElem = BS->getLastElement();
1621-
auto *RS = dyn_cast_or_null<ReturnStmt>(LastElem.dyn_cast<Stmt*>());
1622-
1623-
if (!RS || !RS->isImplicit())
1624-
return false;
1625-
1626-
BS->setLastElement(RS->getResult());
1627-
return true;
1628-
};
1629-
1630-
while (ClosureExpr *CE = dyn_cast_or_null<ClosureExpr>(DC)) {
1631-
if (CE->hasSingleExpressionBody()) {
1632-
if (updateBody(CE->getBody(), CE->getASTContext()))
1633-
CE->setBody(CE->getBody(), false);
1634-
}
1635-
DC = DC->getParent();
1636-
}
1637-
if (FuncDecl *FD = dyn_cast_or_null<FuncDecl>(DC)) {
1638-
if (FD->hasSingleExpressionBody()) {
1639-
if (updateBody(FD->getBody(), FD->getASTContext()))
1640-
FD->setHasSingleExpressionBody(false);
1641-
}
1642-
}
1643-
}
1644-
16451612
void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
16461613
CompletionContext.CodeCompletionKind = Kind;
16471614

@@ -1699,7 +1666,6 @@ void CodeCompletionCallbacksImpl::doneParsing(SourceFile *SrcFile) {
16991666
break;
17001667
}
17011668

1702-
undoSingleExpressionReturn(CurDeclContext);
17031669
if (Kind != CompletionKind::TypeSimpleWithDot) {
17041670
// Type member completion does not need a type-checked AST.
17051671
typeCheckContextAt(

0 commit comments

Comments
 (0)