Skip to content

Commit 725624f

Browse files
committed
[SE-0286] Disable backward scanning for trailing closures in Swift 6 mode.
1 parent cafa252 commit 725624f

File tree

7 files changed

+9
-33
lines changed

7 files changed

+9
-33
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,6 @@ namespace swift {
333333
/// behavior. This is a staging flag, and will be removed in the future.
334334
bool EnableNewOperatorLookup = false;
335335

336-
/// Whether to enable the "fuzzy" forward-scanning behavior for trailing
337-
/// closure matching, which skips over defaulted closure parameters
338-
/// to match later (non-defaulted) closure parameters
339-
///
340-
/// This is a backward-compatibility hack for unlabeled trailing closures,
341-
/// to be disabled in Swift 6+.
342-
bool EnableFuzzyForwardScanTrailingClosureMatching = true;
343-
344336
/// Use Clang function types for computing canonical types.
345337
/// If this option is false, the clang function types will still be computed
346338
/// but will not be used for checking type equality.

include/swift/Option/Options.td

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -580,16 +580,6 @@ def enable_experimental_concise_pound_file : Flag<["-"],
580580
Flags<[FrontendOption, ModuleInterfaceOption]>,
581581
HelpText<"Enable experimental concise '#file' identifier">;
582582

583-
def disable_fuzzy_forward_scan_trailing_closure_matching : Flag<["-"],
584-
"disable-fuzzy-forward-scan-trailing-closure-matching">,
585-
Flags<[FrontendOption]>,
586-
HelpText<"Disable fuzzy forward-scan trailing closure matching">;
587-
588-
def enable_fuzzy_forward_scan_trailing_closure_matching : Flag<["-"],
589-
"enable-fuzzy-forward-scan-trailing-closure-matching">,
590-
Flags<[FrontendOption]>,
591-
HelpText<"Enable fuzzy forward-scan trailing closure matching">;
592-
593583
def enable_experimental_cxx_interop :
594584
Flag<["-"], "enable-experimental-cxx-interop">,
595585
HelpText<"Allow importing C++ modules into Swift (experimental feature)">;

lib/Driver/ToolChains.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
282282
inputArgs.AddLastArg(arguments, options::OPT_diagnostic_style);
283283
inputArgs.AddLastArg(arguments,
284284
options::OPT_enable_experimental_concise_pound_file);
285-
inputArgs.AddLastArg(
286-
arguments,
287-
options::OPT_enable_fuzzy_forward_scan_trailing_closure_matching,
288-
options::OPT_disable_fuzzy_forward_scan_trailing_closure_matching);
289285
inputArgs.AddLastArg(arguments,
290286
options::OPT_verify_incremental_dependencies);
291287
inputArgs.AddLastArg(arguments, options::OPT_access_notes_path);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
659659
Opts.EnableConcisePoundFile =
660660
Args.hasArg(OPT_enable_experimental_concise_pound_file) ||
661661
Opts.EffectiveLanguageVersion.isVersionAtLeast(6);
662-
Opts.EnableFuzzyForwardScanTrailingClosureMatching =
663-
Args.hasFlag(OPT_enable_fuzzy_forward_scan_trailing_closure_matching,
664-
OPT_disable_fuzzy_forward_scan_trailing_closure_matching,
665-
true);
666662

667663
Opts.EnableCrossImportOverlays =
668664
Args.hasFlag(OPT_enable_cross_import_overlays,

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,11 @@ static bool matchCallArgumentsImpl(
446446
}
447447

448448
// If this parameter does not require an argument, consider applying a
449-
// "fuzzy" match rule that skips this parameter if doing so is the only
449+
// backward-match rule that skips this parameter if doing so is the only
450450
// way to successfully match arguments to parameters.
451451
if (!parameterRequiresArgument(params, paramInfo, paramIdx) &&
452-
param.getPlainType()->getASTContext().LangOpts
453-
.EnableFuzzyForwardScanTrailingClosureMatching &&
452+
!param.getPlainType()->getASTContext().LangOpts
453+
.isSwiftVersionAtLeast(6) &&
454454
anyParameterRequiresArgument(
455455
params, paramInfo, paramIdx + 1,
456456
nextArgIdx + 1 < numArgs
@@ -900,9 +900,9 @@ static bool requiresBothTrailingClosureDirections(
900900
if (params.empty())
901901
return false;
902902

903-
// If "fuzzy" matching is disabled, only scan forward.
903+
// If backward matching is disabled, only scan forward.
904904
ASTContext &ctx = params.front().getPlainType()->getASTContext();
905-
if (!ctx.LangOpts.EnableFuzzyForwardScanTrailingClosureMatching)
905+
if (ctx.LangOpts.isSwiftVersionAtLeast(6))
906906
return false;
907907

908908
// If there are at least two parameters that meet the backward scan's

test/expr/postfix/call/forward_trailing_closure.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-typecheck-verify-swift -disable-fuzzy-forward-scan-trailing-closure-matching
1+
// RUN: %target-typecheck-verify-swift -swift-version 6
2+
// REQUIRES: asserts
23

34
func forwardMatch1(
45
a: Int = 0, b: Int = 17, closure1: (Int) -> Int = { $0 }, c: Int = 42,

test/expr/postfix/call/forward_trailing_closure_errors.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-typecheck-verify-swift -disable-fuzzy-forward-scan-trailing-closure-matching
1+
// RUN: %target-typecheck-verify-swift -swift-version 6
2+
// REQUIRES: asserts
23

34
func forwardMatchWithGeneric<T>( // expected-note{{'forwardMatchWithGeneric(closure1:closure2:)' declared here}}
45
closure1: T,

0 commit comments

Comments
 (0)