Skip to content

Commit 7eae5f2

Browse files
committed
[AST] Remove now-unused ClosureExpr::setSingleExpressionBody().
1 parent 2f97d24 commit 7eae5f2

File tree

3 files changed

+0
-34
lines changed

3 files changed

+0
-34
lines changed

include/swift/AST/AnyFunctionRef.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,6 @@ class AnyFunctionRef {
8989
return TheFunction.get<AbstractClosureExpr *>()->getSingleExpressionBody();
9090
}
9191

92-
void setSingleExpressionBody(Expr *expr) {
93-
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
94-
AFD->setSingleExpressionBody(expr);
95-
return;
96-
}
97-
98-
auto ACE = TheFunction.get<AbstractClosureExpr *>();
99-
if (auto CE = dyn_cast<ClosureExpr>(ACE)) {
100-
CE->setSingleExpressionBody(expr);
101-
} else {
102-
cast<AutoClosureExpr>(ACE)->setBody(expr);
103-
}
104-
}
105-
10692
Type getType() const {
10793
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>())
10894
return AFD->getInterfaceType();

include/swift/AST/Expr.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,13 +3891,6 @@ class ClosureExpr : public AbstractClosureExpr {
38913891
/// Only valid when \c hasSingleExpressionBody() is true.
38923892
Expr *getSingleExpressionBody() const;
38933893

3894-
/// Set the body for a closure that has a single expression as its
3895-
/// body.
3896-
///
3897-
/// This routine cannot change whether a closure has a single expression as
3898-
/// its body; it can only update that expression.
3899-
void setSingleExpressionBody(Expr *NewBody);
3900-
39013894
/// Is this a completely empty closure?
39023895
bool hasEmptyBody() const;
39033896

lib/AST/Expr.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,19 +1898,6 @@ Expr *ClosureExpr::getSingleExpressionBody() const {
18981898
return body.get<Expr *>();
18991899
}
19001900

1901-
void ClosureExpr::setSingleExpressionBody(Expr *NewBody) {
1902-
assert(hasSingleExpressionBody() && "Not a single-expression body");
1903-
auto body = getBody()->getFirstElement();
1904-
if (auto stmt = body.dyn_cast<Stmt *>()) {
1905-
if (auto braceStmt = dyn_cast<BraceStmt>(stmt))
1906-
braceStmt->getFirstElement() = NewBody;
1907-
else
1908-
cast<ReturnStmt>(stmt)->setResult(NewBody);
1909-
return;
1910-
}
1911-
getBody()->setFirstElement(NewBody);
1912-
}
1913-
19141901
bool ClosureExpr::hasEmptyBody() const {
19151902
return getBody()->empty();
19161903
}

0 commit comments

Comments
 (0)