Skip to content

Commit 0c957a2

Browse files
authored
Merge pull request #68009 from tshortli/deprecate-warn-on-potentially-unavailable-enum-case
Frontend: Deprecate -warn-on-potentially-unavailable-enum-case option
2 parents c2f1193 + be70c56 commit 0c957a2

File tree

7 files changed

+9
-17
lines changed

7 files changed

+9
-17
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ namespace swift {
206206
/// Should conformance availability violations be diagnosed as errors?
207207
bool EnableConformanceAvailabilityErrors = false;
208208

209-
/// Should potential unavailability on enum cases be downgraded to a warning?
210-
bool WarnOnPotentiallyUnavailableEnumCase = false;
211-
212209
/// Should the editor placeholder error be downgraded to a warning?
213210
bool WarnOnEditorPlaceholder = false;
214211

include/swift/Option/FrontendOptions.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def disable_conformance_availability_errors : Flag<["-"],
617617

618618
def warn_on_potentially_unavailable_enum_case : Flag<["-"],
619619
"warn-on-potentially-unavailable-enum-case">,
620-
HelpText<"Downgrade potential unavailability of enum case to a warning">;
620+
HelpText<"Deprecated, will be removed in future versions">;
621621

622622
def warn_on_editor_placeholder : Flag<["-"],
623623
"warn-on-editor-placeholder">,

lib/Driver/ToolChains.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
177177
arguments.push_back("-aarch64-use-tbi");
178178
}
179179

180-
if (output.getPrimaryOutputType() == file_types::TY_SwiftModuleFile) {
181-
arguments.push_back("-warn-on-potentially-unavailable-enum-case");
182-
}
183-
184180
// Enable or disable ObjC interop appropriately for the platform
185181
if (Triple.isOSDarwin()) {
186182
arguments.push_back("-enable-objc-interop");

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
642642
if (Args.hasArg(OPT_check_api_availability_only))
643643
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
644644
"-check-api-availability-only");
645+
if (Args.hasArg(OPT_warn_on_potentially_unavailable_enum_case))
646+
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
647+
"-warn-on-potentially-unavailable-enum-case");
645648

646649
if (const Arg *A = Args.getLastArg(OPT_unavailable_decl_optimization_EQ)) {
647650
auto value =
@@ -667,8 +670,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
667670
= A->getOption().matches(OPT_enable_conformance_availability_errors);
668671
}
669672

670-
Opts.WarnOnPotentiallyUnavailableEnumCase |=
671-
Args.hasArg(OPT_warn_on_potentially_unavailable_enum_case);
672673
Opts.WarnOnEditorPlaceholder |= Args.hasArg(OPT_warn_on_editor_placeholder);
673674

674675
if (auto A = Args.getLastArg(OPT_disable_typo_correction,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4468,11 +4468,9 @@ TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable(const Decl *D) {
44684468
// An enum element with an associated value cannot be potentially
44694469
// unavailable.
44704470
if (EED->hasAssociatedValues()) {
4471-
auto &ctx = DC->getASTContext();
44724471
auto *SF = DC->getParentSourceFile();
44734472

4474-
if (SF->Kind == SourceFileKind::Interface ||
4475-
ctx.LangOpts.WarnOnPotentiallyUnavailableEnumCase) {
4473+
if (SF->Kind == SourceFileKind::Interface) {
44764474
return diag::availability_enum_element_no_potential_warn;
44774475
} else {
44784476
return diag::availability_enum_element_no_potential;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
public enum Horse {
2-
@available(macOS 100, *)
2+
@available(macOS 10.50, *)
33
case kevin(Int)
44
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %empty-directory(%t)
22

3-
// RUN: %target-build-swift -emit-module %S/Inputs/availability_enum_case_other.swift -emit-module-interface-path %t/availability_enum_case_other.swiftinterface -swift-version 5 -enable-library-evolution
3+
// RUN: %target-build-swift -emit-module %S/Inputs/availability_enum_case_other.swift -target %target-cpu-apple-macosx10.50 -emit-module-interface-path %t/availability_enum_case_other.swiftinterface -swift-version 5 -enable-library-evolution
44
// RUN: %target-typecheck-verify-swift -I %t
55

6-
// RUN: %target-build-swift -emit-module %S/Inputs/availability_enum_case_other.swift -emit-module-interface-path %t/availability_enum_case_other.swiftinterface -swift-version 5 -enable-library-evolution -whole-module-optimization
6+
// RUN: %target-build-swift -emit-module %S/Inputs/availability_enum_case_other.swift -target %target-cpu-apple-macosx10.50 -emit-module-interface-path %t/availability_enum_case_other.swiftinterface -swift-version 5 -enable-library-evolution -whole-module-optimization
77
// RUN: %target-typecheck-verify-swift -I %t
88

99
// REQUIRES: OS=macosx
@@ -14,6 +14,6 @@ func ride(horse: Horse) {
1414
// expected-note@-1 {{add @available attribute to enclosing global function}}
1515

1616
_ = Horse.kevin
17-
// expected-error@-1 {{'kevin' is only available in macOS 100 or newer}}
17+
// expected-error@-1 {{'kevin' is only available in macOS 10.50 or newer}}
1818
// expected-note@-2 {{add 'if #available' version check}}
1919
}

0 commit comments

Comments
 (0)