mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user