Skip to content

Commit c3d1953

Browse files
committed
[Sema] Enable require explicit availability by default for public modules
rdar://99929744
1 parent ce219cc commit c3d1953

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
728728
diagLevel);
729729
}
730730
} else if (Args.getLastArg(OPT_require_explicit_availability,
731-
OPT_require_explicit_availability_target)) {
731+
OPT_require_explicit_availability_target) ||
732+
Opts.LibraryLevel == LibraryLevel::API) {
732733
Opts.RequireExplicitAvailability = DiagnosticBehavior::Warning;
733734
}
734735

test/attr/require_explicit_availability.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
// RUN: -target %target-cpu-apple-macosx10.10 -require-explicit-availability=warn \
1111
// RUN: -require-explicit-availability-target "macOS 10.10"
1212

13+
/// Using -library-level api defaults to enabling warnings, without fixits.
14+
// RUN: sed -e "s/}} {{.*/}}/" < %s > %t/NoFixits.swift
15+
// RUN: %target-swift-frontend -typecheck -parse-as-library -verify %t/NoFixits.swift \
16+
// RUN: -target %target-cpu-apple-macosx10.10 -library-level api
17+
18+
/// Explicitly disable the diagnostic.
19+
// RUN: sed -e 's/xpected-warning/not-something-expected/' < %s > %t/None.swift
20+
// RUN: %target-swift-frontend -typecheck -parse-as-library -verify %t/None.swift \
21+
// RUN: -target %target-cpu-apple-macosx10.10 -require-explicit-availability=ignore \
22+
// RUN: -require-explicit-availability-target "macOS 10.10" -library-level api
23+
1324
/// Upgrade the diagnostic to an error.
1425
// RUN: sed -e "s/xpected-warning/xpected-error/" < %s > %t/Errors.swift
1526
// RUN: %target-swift-frontend -typecheck -parse-as-library -verify %t/Errors.swift \

0 commit comments

Comments
 (0)