Skip to content

Commit 1c426a3

Browse files
authored
Merge pull request #42484 from xedin/drop-se-0326-flag
[TypeChecker] NFC: Remove `-experimental-multi-statement-closures` flag
2 parents f4a5f85 + 6db0001 commit 1c426a3

File tree

11 files changed

+12
-52
lines changed

11 files changed

+12
-52
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,6 @@ namespace swift {
759759
/// parameters of closures.
760760
bool EnableOneWayClosureParameters = false;
761761

762-
/// Enable experimental support for type inference through multi-statement
763-
/// closures.
764-
bool EnableMultiStatementClosureInference = true;
765-
766762
/// See \ref FrontendOptions.PrintFullConvention
767763
bool PrintFullConvention = false;
768764
};

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,6 @@ def experimental_one_way_closure_params :
900900
Flag<["-"], "experimental-one-way-closure-params">,
901901
HelpText<"Enable experimental support for one-way closure parameters">;
902902

903-
def experimental_multi_statement_closures :
904-
Flag<["-"], "experimental-multi-statement-closures">,
905-
HelpText<"Enable experimental support for type inference in multi-statement closures">;
906-
907903
def prebuilt_module_cache_path :
908904
Separate<["-"], "prebuilt-module-cache-path">,
909905
HelpText<"Directory of prebuilt modules for loading module interfaces">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,9 +1146,6 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
11461146
Opts.EnableOneWayClosureParameters |=
11471147
Args.hasArg(OPT_experimental_one_way_closure_params);
11481148

1149-
Opts.EnableMultiStatementClosureInference |=
1150-
Args.hasArg(OPT_experimental_multi_statement_closures);
1151-
11521149
Opts.PrintFullConvention |=
11531150
Args.hasArg(OPT_experimental_print_full_convention);
11541151

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6639,9 +6639,7 @@ bool ConstraintSystem::participatesInInference(ClosureExpr *closure) const {
66396639
if (Options.contains(ConstraintSystemFlags::LeaveClosureBodyUnchecked))
66406640
return false;
66416641

6642-
auto &ctx = closure->getASTContext();
6643-
if (closure->hasEmptyBody() ||
6644-
!ctx.TypeCheckerOpts.EnableMultiStatementClosureInference)
6642+
if (closure->hasEmptyBody())
66456643
return false;
66466644

66476645
// If body is nested in a parent that has a function builder applied,

lib/Sema/MiscDiagnostics.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,10 @@ bool BaseDiagnosticWalker::shouldWalkIntoDeclInClosureContext(Decl *D) {
6464
if (closure->isSeparatelyTypeChecked())
6565
return false;
6666

67-
auto &opts = D->getASTContext().TypeCheckerOpts;
68-
69-
// If multi-statement inference is enabled, let's not walk
70-
// into declarations contained in a multi-statement closure
71-
// because they'd be handled via `typeCheckDecl` that runs
67+
// Let's not walk into declarations contained in a multi-statement
68+
// closure because they'd be handled via `typeCheckDecl` that runs
7269
// syntactic diagnostics.
73-
if (opts.EnableMultiStatementClosureInference &&
74-
!closure->hasSingleExpressionBody()) {
70+
if (!closure->hasSingleExpressionBody()) {
7571
// Since pattern bindings get their types through solution application,
7672
// `typeCheckDecl` doesn't touch initializers (because they are already
7773
// fully type-checked), so pattern bindings have to be allowed to be

lib/Sema/PreCheckExpr.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,12 +1443,10 @@ namespace {
14431443
bool walkToDeclPre(Decl *D) override { return isa<PatternBindingDecl>(D); }
14441444

14451445
std::pair<bool, Pattern *> walkToPatternPre(Pattern *pattern) override {
1446-
// With multi-statement closure inference enabled, constraint generation
1447-
// is responsible for pattern verification and type-checking in the body
1448-
// of the closure, so there is no need to walk into patterns.
1449-
bool walkIntoPatterns =
1450-
!(isa<ClosureExpr>(DC) &&
1451-
Ctx.TypeCheckerOpts.EnableMultiStatementClosureInference);
1446+
// Constraint generation is responsible for pattern verification and
1447+
// type-checking in the body of the closure, so there is no need to
1448+
// walk into patterns.
1449+
bool walkIntoPatterns = !isa<ClosureExpr>(DC);
14521450
return {walkIntoPatterns, pattern};
14531451
}
14541452
};
@@ -1461,9 +1459,6 @@ bool PreCheckExpression::walkToClosureExprPre(ClosureExpr *closure) {
14611459
if (!closure->hasSingleExpressionBody()) {
14621460
if (LeaveClosureBodiesUnchecked)
14631461
return false;
1464-
1465-
if (!Ctx.TypeCheckerOpts.EnableMultiStatementClosureInference)
1466-
return false;
14671462
}
14681463

14691464
// Update the current DeclContext to be the closure we're about to

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,21 +3136,7 @@ class ExprAvailabilityWalker : public ASTWalker {
31363136
}
31373137

31383138
bool shouldWalkIntoClosure(AbstractClosureExpr *closure) const {
3139-
// Multi-statement closures are collected by ExprWalker::rewriteFunction
3140-
// and checked by ExprWalker::processDelayed in CSApply.cpp.
3141-
// Single-statement closures only have the attributes checked
3142-
// by TypeChecker::checkClosureAttributes in that rewriteFunction.
3143-
// Multi-statement closures will be checked explicitly later (as the decl
3144-
// context in the Where). Single-expression closures will not be
3145-
// revisited, and are not automatically set as the context of the 'where'.
3146-
// Don't double-check multi-statement closures, but do check
3147-
// single-statement closures, setting the closure as the decl context.
3148-
//
3149-
// Note about SE-0326: When a flag is enabled multi-statement closures
3150-
// are type-checked together with enclosing context, so walker behavior
3151-
// should match that of single-expression closures.
3152-
return closure->hasSingleExpressionBody() ||
3153-
Context.TypeCheckerOpts.EnableMultiStatementClosureInference;
3139+
return true;
31543140
}
31553141

31563142
/// Walk an abstract closure expression, checking for availability

lib/Sema/TypeCheckCodeCompletion.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ class SanitizeExpr : public ASTWalker {
212212
// If this is a closure, only walk into its children if they
213213
// are type-checked in the context of the enclosing expression.
214214
if (auto closure = dyn_cast<ClosureExpr>(expr)) {
215-
// TODO: This has to be deleted once `EnableMultiStatementClosureInference`
216-
// is enabled by default.
217-
if (!closure->hasSingleExpressionBody())
218-
return { false, expr };
219215
for (auto &Param : *closure->getParameters()) {
220216
Param->setSpecifier(swift::ParamSpecifier::Default);
221217
}

test/expr/closure/multi_statement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -swift-version 5 -experimental-multi-statement-closures -enable-experimental-static-assert
1+
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-experimental-static-assert
22

33
func isInt<T>(_ value: T) -> Bool {
44
return value is Int

validation-test/Sema/SwiftUI/mixed_swiftui_and_multistatement_closures.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5 -experimental-multi-statement-closures
1+
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5
22
// REQUIRES: objc_interop
33
// REQUIRES: OS=macosx
44

validation-test/Sema/type_checker_crashers_fixed/rdar85843677.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -swift-version 5 -experimental-multi-statement-closures
1+
// RUN: %target-typecheck-verify-swift -swift-version 5
22

33
func callClosure(closure: () -> ()) {
44
closure()

0 commit comments

Comments
 (0)