@@ -1926,7 +1926,7 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(Evaluator &evaluator,
1926
1926
func->getResultInterfaceType ()->isVoid ()) {
1927
1927
// The function returns void. We don't need an explicit return, no matter
1928
1928
// what the type of the expression is. Take the inserted return back out.
1929
- func->getBody ()->getElements (). back () = func->getSingleExpressionBody ();
1929
+ func->getBody ()->setLastElement ( func->getSingleExpressionBody () );
1930
1930
}
1931
1931
}
1932
1932
@@ -1991,7 +1991,7 @@ TypeCheckFunctionBodyRequest::evaluate(Evaluator &evaluator,
1991
1991
func->getResultInterfaceType ()->isVoid ()) {
1992
1992
// The function returns void. We don't need an explicit return, no matter
1993
1993
// what the type of the expression is. Take the inserted return back out.
1994
- body->getElements (). back () = func->getSingleExpressionBody ();
1994
+ body->setLastElement ( func->getSingleExpressionBody () );
1995
1995
}
1996
1996
} else if (isa<ConstructorDecl>(AFD) &&
1997
1997
(body->empty () ||
@@ -2025,12 +2025,12 @@ TypeCheckFunctionBodyRequest::evaluate(Evaluator &evaluator,
2025
2025
// that we have eagerly converted something like `{ fatalError() }`
2026
2026
// into `{ return fatalError() }` that has to be corrected here.
2027
2027
if (isa<FuncDecl>(AFD) && cast<FuncDecl>(AFD)->hasSingleExpressionBody ()) {
2028
- if (auto *stmt = body->getElements (). back ().dyn_cast <Stmt *>()) {
2028
+ if (auto *stmt = body->getLastElement ().dyn_cast <Stmt *>()) {
2029
2029
if (auto *retStmt = dyn_cast<ReturnStmt>(stmt)) {
2030
2030
if (retStmt->isImplicit () && retStmt->hasResult ()) {
2031
2031
auto returnType = retStmt->getResult ()->getType ();
2032
2032
if (returnType && returnType->isUninhabited ())
2033
- body->getElements (). back () = retStmt->getResult ();
2033
+ body->setLastElement ( retStmt->getResult () );
2034
2034
}
2035
2035
}
2036
2036
}
0 commit comments