Revert "[TypeChecker] SE-0326: Enable multi-statement closure inference by default"

This commit is contained in:
Pavel Yaskevich
2021-11-29 17:26:08 -08:00
committed by GitHub
parent e7120a61ad
commit bc54bc6bb7
49 changed files with 247 additions and 480 deletions

View File

@@ -4854,8 +4854,8 @@ private:
/// Simplify a closure body element constraint by generating required
/// constraints to represent the given element in constraint system.
SolutionKind simplifyClosureBodyElementConstraint(
ASTNode element, ContextualTypeInfo context, bool isDiscarded,
TypeMatchOptions flags, ConstraintLocatorBuilder locator);
ASTNode element, ContextualTypeInfo context, TypeMatchOptions flags,
ConstraintLocatorBuilder locator);
public: // FIXME: Public for use by static functions.
/// Simplify a conversion constraint with a fix applied to it.
@@ -5014,8 +5014,7 @@ public:
/// \param replaceInvalidRefsWithErrors Indicates whether it's allowed
/// to replace any discovered invalid member references with `ErrorExpr`.
static bool preCheckExpression(Expr *&expr, DeclContext *dc,
bool replaceInvalidRefsWithErrors,
bool leaveClosureBodiesUnchecked);
bool replaceInvalidRefsWithErrors);
/// Solve the system of constraints generated from provided target.
///
@@ -5246,16 +5245,6 @@ public:
/// imported from C/ObjectiveC.
bool isArgumentOfImportedDecl(ConstraintLocatorBuilder locator);
/// Check whether given closure should participate in inference e.g.
/// if it's a single-expression closure - it always does, but
/// multi-statement closures require special flags.
bool participatesInInference(ClosureExpr *closure) const;
/// Visit each subexpression that will be part of the constraint system
/// of the given expression, including those in closure bodies that will be
/// part of the constraint system.
void forEachExpr(Expr *expr, llvm::function_ref<Expr *(Expr *)> callback);
SWIFT_DEBUG_DUMP;
SWIFT_DEBUG_DUMPER(dump(Expr *));
@@ -6080,6 +6069,18 @@ BraceStmt *applyResultBuilderTransform(
constraints::SolutionApplicationTarget)>
rewriteTarget);
/// Determine whether the given closure expression should be type-checked
/// within the context of its enclosing expression. Otherwise, it will be
/// separately type-checked once its enclosing expression has determined all
/// of the parameter and result types without looking at the body.
bool shouldTypeCheckInEnclosingExpression(ClosureExpr *expr);
/// Visit each subexpression that will be part of the constraint system
/// of the given expression, including those in closure bodies that will be
/// part of the constraint system.
void forEachExprInConstraintSystem(
Expr *expr, llvm::function_ref<Expr *(Expr *)> callback);
/// Whether the given parameter requires an argument.
bool parameterRequiresArgument(
ArrayRef<AnyFunctionType::Param> params,