Skip to content

Commit d5a3e36

Browse files
committed
[AST] Remove AbstractFunctionDecl::setSingleExpressionBody
This is now unused.
1 parent 3a82241 commit d5a3e36

File tree

2 files changed

+0
-22
lines changed

2 files changed

+0
-22
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7220,7 +7220,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
72207220
}
72217221

72227222
Expr *getSingleExpressionBody() const;
7223-
void setSingleExpressionBody(Expr *NewBody);
72247223

72257224
/// Returns the string for the base name, or "_" if this is unnamed.
72267225
StringRef getNameStr() const {

lib/AST/Decl.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,27 +1029,6 @@ Expr *AbstractFunctionDecl::getSingleExpressionBody() const {
10291029
return body.get<Expr *>();
10301030
}
10311031

1032-
void AbstractFunctionDecl::setSingleExpressionBody(Expr *NewBody) {
1033-
assert(hasSingleExpressionBody() && "Not a single-expression body");
1034-
auto body = getBody(/*canSynthesize=*/false)->getLastElement();
1035-
if (auto *stmt = body.dyn_cast<Stmt *>()) {
1036-
if (auto *returnStmt = dyn_cast<ReturnStmt>(stmt)) {
1037-
returnStmt->setResult(NewBody);
1038-
return;
1039-
} else if (isa<FailStmt>(stmt)) {
1040-
// We can only get to this point if we're a type-checked ConstructorDecl
1041-
// which was originally spelled init?(...) { nil }.
1042-
//
1043-
// We can no longer write the single-expression which is being set on us
1044-
// into anything because a FailStmt does not have such a child. As a
1045-
// result we need to demand that the NewBody is null.
1046-
assert(NewBody == nullptr);
1047-
return;
1048-
}
1049-
}
1050-
getBody()->setLastElement(NewBody);
1051-
}
1052-
10531032
bool AbstractStorageDecl::isCompileTimeConst() const {
10541033
return getAttrs().hasAttribute<CompileTimeConstAttr>();
10551034
}

0 commit comments

Comments
 (0)