[AST] Remove the "single expression body" bit

Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
This commit is contained in:
Hamish Knight
2024-01-30 14:08:54 +00:00
parent 9cf8f5b1f0
commit 9b64990d24
25 changed files with 160 additions and 161 deletions

View File

@@ -1212,7 +1212,7 @@ Type ConstraintSystem::openOpaqueType(Type type, ContextualTypePurpose context,
return type;
auto inReturnContext = [](ContextualTypePurpose context) {
return context == CTP_ReturnStmt || context == CTP_ReturnSingleExpr;
return context == CTP_ReturnStmt || context == CTP_ImpliedReturnStmt;
};
if (!(context == CTP_Initialization || inReturnContext(context)))
@@ -7028,7 +7028,7 @@ Expr *ConstraintSystem::buildAutoClosureExpr(Expr *expr,
Expr *ConstraintSystem::buildTypeErasedExpr(Expr *expr, DeclContext *dc,
Type contextualType,
ContextualTypePurpose purpose) {
if (!(purpose == CTP_ReturnStmt || purpose == CTP_ReturnSingleExpr))
if (!(purpose == CTP_ReturnStmt || purpose == CTP_ImpliedReturnStmt))
return expr;
auto *decl = dyn_cast_or_null<ValueDecl>(dc->getAsDecl());