Skip to content

Commit 41c4143

Browse files
committed
Frontend: Remove conformance availability error flags.
Now that the diagnostics are automatically errors in Swift 6, we don't need an `-enable-conformance-availability-errors` flag to control whether unavailable conformances are diagnosed as errors. Nobody was using the flag so it should be safe to remove. Part of rdar://88210812
1 parent c165a2c commit 41c4143

8 files changed

+26
-48
lines changed

include/swift/Basic/LangOptions.h

-3
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ namespace swift {
204204
/// declarations introduced at the deployment target.
205205
bool WeakLinkAtTarget = false;
206206

207-
/// Should conformance availability violations be diagnosed as errors?
208-
bool EnableConformanceAvailabilityErrors = false;
209-
210207
/// Should the editor placeholder error be downgraded to a warning?
211208
bool WarnOnEditorPlaceholder = false;
212209

include/swift/Option/FrontendOptions.td

-8
Original file line numberDiff line numberDiff line change
@@ -664,14 +664,6 @@ def disable_availability_checking : Flag<["-"],
664664
"disable-availability-checking">,
665665
HelpText<"Disable checking for potentially unavailable APIs">;
666666

667-
def enable_conformance_availability_errors : Flag<["-"],
668-
"enable-conformance-availability-errors">,
669-
HelpText<"Diagnose conformance availability violations as errors">;
670-
671-
def disable_conformance_availability_errors : Flag<["-"],
672-
"disable-conformance-availability-errors">,
673-
HelpText<"Diagnose conformance availability violations as warnings">;
674-
675667
def warn_on_potentially_unavailable_enum_case : Flag<["-"],
676668
"warn-on-potentially-unavailable-enum-case">,
677669
HelpText<"Deprecated, will be removed in future versions">;

lib/Frontend/CompilerInvocation.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -677,12 +677,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
677677

678678
Opts.WeakLinkAtTarget |= Args.hasArg(OPT_weak_link_at_target);
679679

680-
if (auto A = Args.getLastArg(OPT_enable_conformance_availability_errors,
681-
OPT_disable_conformance_availability_errors)) {
682-
Opts.EnableConformanceAvailabilityErrors
683-
= A->getOption().matches(OPT_enable_conformance_availability_errors);
684-
}
685-
686680
Opts.WarnOnEditorPlaceholder |= Args.hasArg(OPT_warn_on_editor_placeholder);
687681

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

lib/Sema/ResilienceDiagnostics.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ TypeChecker::diagnoseConformanceExportability(SourceLoc loc,
347347
const RootProtocolConformance *rootConf,
348348
const ExtensionDecl *ext,
349349
const ExportContext &where,
350-
bool useConformanceAvailabilityErrorsOption) {
350+
bool warnIfConformanceUnavailablePreSwift6) {
351351
if (!where.mustOnlyReferenceExportedDecls())
352352
return false;
353353

@@ -390,8 +390,7 @@ TypeChecker::diagnoseConformanceExportability(SourceLoc loc,
390390
static_cast<unsigned>(*reason),
391391
M->getName(),
392392
static_cast<unsigned>(originKind))
393-
.warnUntilSwiftVersionIf((useConformanceAvailabilityErrorsOption &&
394-
!ctx.LangOpts.EnableConformanceAvailabilityErrors &&
393+
.warnUntilSwiftVersionIf((warnIfConformanceUnavailablePreSwift6 &&
395394
originKind != DisallowedOriginKind::SPIOnly &&
396395
originKind != DisallowedOriginKind::NonPublicImport) ||
397396
originKind == DisallowedOriginKind::MissingImport,

lib/Sema/TypeCheckAvailability.cpp

+11-14
Original file line numberDiff line numberDiff line change
@@ -2187,8 +2187,7 @@ void TypeChecker::diagnosePotentialUnavailability(
21872187
prettyPlatformString(targetPlatform(ctx.LangOpts)),
21882188
reason.getRequiredOSVersionRange().getLowerEndpoint());
21892189

2190-
err.warnUntilSwiftVersionIf(
2191-
!ctx.LangOpts.EnableConformanceAvailabilityErrors, 6);
2190+
err.warnUntilSwiftVersion(6);
21922191
err.limitBehavior(behaviorLimitForExplicitUnavailability(rootConf, dc));
21932192

21942193
// Direct a fixit to the error if an existing guard is nearly-correct
@@ -2813,7 +2812,7 @@ bool swift::diagnoseExplicitUnavailability(SourceLoc loc,
28132812
const RootProtocolConformance *rootConf,
28142813
const ExtensionDecl *ext,
28152814
const ExportContext &where,
2816-
bool useConformanceAvailabilityErrorsOption) {
2815+
bool warnIfConformanceUnavailablePreSwift6) {
28172816
auto *attr = AvailableAttr::isUnavailable(ext);
28182817
if (!attr)
28192818
return false;
@@ -2871,9 +2870,7 @@ bool swift::diagnoseExplicitUnavailability(SourceLoc loc,
28712870
type, proto,
28722871
platform.empty(), platform, EncodedMessage.Message)
28732872
.limitBehavior(behavior)
2874-
.warnUntilSwiftVersionIf(useConformanceAvailabilityErrorsOption &&
2875-
!ctx.LangOpts.EnableConformanceAvailabilityErrors,
2876-
6);
2873+
.warnUntilSwiftVersionIf(warnIfConformanceUnavailablePreSwift6, 6);
28772874

28782875
switch (attr->getVersionAvailability(ctx)) {
28792876
case AvailableVersionComparison::Available:
@@ -4003,7 +4000,7 @@ class ProblematicTypeFinder : public TypeDeclFinder {
40034000
Loc, subs, Where,
40044001
/*depTy=*/Type(),
40054002
/*replacementTy=*/Type(),
4006-
/*useConformanceAvailabilityErrorsOption=*/false,
4003+
/*warnIfConformanceUnavailablePreSwift6=*/false,
40074004
/*suppressParameterizationCheckForOptional=*/ty->isOptional());
40084005
return Action::Continue;
40094006
}
@@ -4082,7 +4079,7 @@ swift::diagnoseConformanceAvailability(SourceLoc loc,
40824079
ProtocolConformanceRef conformance,
40834080
const ExportContext &where,
40844081
Type depTy, Type replacementTy,
4085-
bool useConformanceAvailabilityErrorsOption) {
4082+
bool warnIfConformanceUnavailablePreSwift6) {
40864083
assert(!where.isImplicit());
40874084

40884085
if (conformance.isPack()) {
@@ -4091,7 +4088,7 @@ swift::diagnoseConformanceAvailability(SourceLoc loc,
40914088
for (auto patternConf : pack->getPatternConformances()) {
40924089
diagnosed |= diagnoseConformanceAvailability(
40934090
loc, patternConf, where, depTy, replacementTy,
4094-
useConformanceAvailabilityErrorsOption);
4091+
warnIfConformanceUnavailablePreSwift6);
40954092
}
40964093
return diagnosed;
40974094
}
@@ -4128,13 +4125,13 @@ swift::diagnoseConformanceAvailability(SourceLoc loc,
41284125

41294126
if (auto *ext = dyn_cast<ExtensionDecl>(rootConf->getDeclContext())) {
41304127
if (TypeChecker::diagnoseConformanceExportability(loc, rootConf, ext, where,
4131-
useConformanceAvailabilityErrorsOption)) {
4128+
warnIfConformanceUnavailablePreSwift6)) {
41324129
maybeEmitAssociatedTypeNote();
41334130
return true;
41344131
}
41354132

41364133
if (diagnoseExplicitUnavailability(loc, rootConf, ext, where,
4137-
useConformanceAvailabilityErrorsOption)) {
4134+
warnIfConformanceUnavailablePreSwift6)) {
41384135
maybeEmitAssociatedTypeNote();
41394136
return true;
41404137
}
@@ -4162,7 +4159,7 @@ swift::diagnoseConformanceAvailability(SourceLoc loc,
41624159
SubstitutionMap subConformanceSubs = concreteConf->getSubstitutionMap();
41634160
if (diagnoseSubstitutionMapAvailability(loc, subConformanceSubs, where,
41644161
depTy, replacementTy,
4165-
useConformanceAvailabilityErrorsOption))
4162+
warnIfConformanceUnavailablePreSwift6))
41664163
return true;
41674164

41684165
return false;
@@ -4173,13 +4170,13 @@ swift::diagnoseSubstitutionMapAvailability(SourceLoc loc,
41734170
SubstitutionMap subs,
41744171
const ExportContext &where,
41754172
Type depTy, Type replacementTy,
4176-
bool useConformanceAvailabilityErrorsOption,
4173+
bool warnIfConformanceUnavailablePreSwift6,
41774174
bool suppressParameterizationCheckForOptional) {
41784175
bool hadAnyIssues = false;
41794176
for (ProtocolConformanceRef conformance : subs.getConformances()) {
41804177
if (diagnoseConformanceAvailability(loc, conformance, where,
41814178
depTy, replacementTy,
4182-
useConformanceAvailabilityErrorsOption))
4179+
warnIfConformanceUnavailablePreSwift6))
41834180
hadAnyIssues = true;
41844181
}
41854182

lib/Sema/TypeCheckAvailability.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,15 @@ diagnoseConformanceAvailability(SourceLoc loc,
227227
const ExportContext &context,
228228
Type depTy=Type(),
229229
Type replacementTy=Type(),
230-
bool useConformanceAvailabilityErrorsOption = false);
230+
bool warnIfConformanceUnavailablePreSwift6 = false);
231231

232232
bool diagnoseSubstitutionMapAvailability(
233233
SourceLoc loc,
234234
SubstitutionMap subs,
235235
const ExportContext &context,
236236
Type depTy = Type(),
237237
Type replacementTy = Type(),
238-
bool useConformanceAvailabilityErrorsOption = false,
238+
bool warnIfConformanceUnavailablePreSwift6 = false,
239239
bool suppressParameterizationCheckForOptional = false);
240240

241241
/// Diagnose uses of unavailable declarations. Returns true if a diagnostic
@@ -273,7 +273,7 @@ bool diagnoseExplicitUnavailability(
273273
const RootProtocolConformance *rootConf,
274274
const ExtensionDecl *ext,
275275
const ExportContext &where,
276-
bool useConformanceAvailabilityErrorsOption = false);
276+
bool warnIfConformanceUnavailablePreSwift6 = false);
277277

278278
/// Diagnose uses of the runtime features of parameterized protools. Returns
279279
/// \c true if a diagnostic was emitted.

test/Sema/conformance_availability.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-conformance-availability-errors
21
// RUN: %target-typecheck-verify-swift -swift-version 6
32

43
// REQUIRES: OS=macosx
@@ -247,9 +246,9 @@ public struct HasAvailableConformance1 {}
247246
extension HasAvailableConformance1 : Horse {}
248247

249248
// These availability violations are errors because this test passes the
250-
// -enable-conformance-availability-errors flag. See the other test case
251-
// in test/Sema/conformance_availability_warn.swift for the same example
252-
// but without this flag.
249+
// -swift-version 6.
250+
// See the other test case in test/Sema/conformance_availability_warn.swift for
251+
// the same example for -swift-version 5.
253252

254253
func passAvailableConformance1(x: HasAvailableConformance1) { // expected-note 6{{add @available attribute to enclosing global function}}
255254
takesHorse(x) // expected-error {{conformance of 'HasAvailableConformance1' to 'Horse' is only available in macOS 100 or newer}}

test/Sema/conformance_availability_warn.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public struct HasAvailableConformance1 {}
1919
@available(macOS 100, *)
2020
extension HasAvailableConformance1 : Horse {}
2121

22-
// These availability violations are warnings because this test does not
23-
// pass the -enable-conformance-availability-errors flag. See the other
24-
// test case in test/Sema/conformance_availability.swift for the same
25-
// example but with this flag.
22+
// These availability violations are warnings because this test does not pass
23+
// -swift-version 6.
24+
// See the other test case in test/Sema/conformance_availability.swift for the
25+
// same example but with -swift-version 6.
2626

2727
func passAvailableConformance1(x: HasAvailableConformance1) { // expected-note 6{{add @available attribute to enclosing global function}}
2828
takesHorse(x) // expected-warning {{conformance of 'HasAvailableConformance1' to 'Horse' is only available in macOS 100 or newer; this is an error in Swift 6}}
@@ -60,9 +60,9 @@ public struct HasAvailableConformance2 {}
6060
extension HasAvailableConformance2 : Horse {} // expected-note 6 {{conformance of 'HasAvailableConformance2' to 'Horse' has been explicitly marked unavailable here}}
6161

6262
// Some availability diagnostics become warnings in Swift 5 mode without
63-
// -enable-conformance-availability-errors because they were incorrectly
64-
// accepted before and rejecting them would break source compatibility. Others
65-
// are unaffected because they have always been rejected.
63+
// because they were incorrectly accepted before and rejecting them would break
64+
// source compatibility. Others are unaffected because they have always been
65+
// rejected.
6666

6767
func passAvailableConformance2(x: HasAvailableConformance2) {
6868
takesHorse(x) // expected-error {{conformance of 'HasAvailableConformance2' to 'Horse' is unavailable}}

0 commit comments

Comments
 (0)