From 2fbef52d16a92c9c881799c15745e6df3c64eaec Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Mon, 8 Jan 2024 12:25:58 -0800 Subject: [PATCH] Frontend: Hide and deprecate options for Swift 3 @objc inference. The compiler has not supported migrating Swift 3 code to Swift 4 for a long time. The `-enable-swift3-objc-inference` option and related options were originally designed to aid that transition and should be deprecated at this point. Resolves rdar://120490061 --- include/swift/Option/FrontendOptions.td | 4 ++-- include/swift/Option/Options.td | 8 ++++---- lib/Frontend/CompilerInvocation.cpp | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/swift/Option/FrontendOptions.td b/include/swift/Option/FrontendOptions.td index 5dd6f0cf174ad..f6f62459aa39e 100644 --- a/include/swift/Option/FrontendOptions.td +++ b/include/swift/Option/FrontendOptions.td @@ -677,12 +677,12 @@ def report_errors_to_debugger : Flag<["-"], "report-errors-to-debugger">, def enable_swift3_objc_inference : Flag<["-"], "enable-swift3-objc-inference">, Flags<[FrontendOption, HelpHidden]>, -HelpText<"Enable Swift 3's @objc inference rules for NSObject-derived classes and 'dynamic' members (emulates Swift 3 behavior)">; +HelpText<"Deprecated">; def disable_swift3_objc_inference : Flag<["-"], "disable-swift3-objc-inference">, Flags<[FrontendOption, HelpHidden]>, - HelpText<"Disable Swift 3's @objc inference rules for NSObject-derived classes and 'dynamic' members (emulates Swift 4 behavior)">; + HelpText<"Deprecated">; def enable_implicit_dynamic : Flag<["-"], "enable-implicit-dynamic">, Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>, diff --git a/include/swift/Option/Options.td b/include/swift/Option/Options.td index 9913e999354cd..ca2f66c0ee716 100644 --- a/include/swift/Option/Options.td +++ b/include/swift/Option/Options.td @@ -787,13 +787,13 @@ def continue_building_after_errors : Flag<["-"], "continue-building-after-errors def warn_swift3_objc_inference_complete : Flag<["-"], "warn-swift3-objc-inference-complete">, - Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>, - HelpText<"Warn about deprecated @objc inference in Swift 3 for every declaration that will no longer be inferred as @objc in Swift 4">; + Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>, + HelpText<"Deprecated">; def warn_swift3_objc_inference_minimal : Flag<["-"], "warn-swift3-objc-inference-minimal">, - Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>, - HelpText<"Warn about deprecated @objc inference in Swift 3 based on direct uses of the Objective-C entrypoint">; + Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>, + HelpText<"Deprecated">; def enable_actor_data_race_checks : Flag<["-"], "enable-actor-data-race-checks">, diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 99da758272d91..4696311f4bd1a 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -920,6 +920,14 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args, Args.hasFlag(OPT_enable_swift3_objc_inference, OPT_disable_swift3_objc_inference, false); + if (Args.hasArg(OPT_enable_swift3_objc_inference)) + Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated, + "-enable-swift3-objc-inference"); + + if (Args.hasArg(OPT_disable_swift3_objc_inference)) + Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated, + "-disable-swift3-objc-inference"); + if (const Arg *A = Args.getLastArg(OPT_library_level)) { StringRef contents = A->getValue(); if (contents == "api") { @@ -983,6 +991,14 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args, } } + if (Args.hasArg(OPT_warn_swift3_objc_inference_minimal)) + Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated, + "-warn-swift3-objc-inference-minimal"); + + if (Args.hasArg(OPT_warn_swift3_objc_inference_complete)) + Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated, + "-warn-swift3-objc-inference-complete"); + // Swift 6+ uses the strictest concurrency level. if (Opts.isSwiftVersionAtLeast(6)) { Opts.StrictConcurrencyLevel = StrictConcurrency::Complete;