Skip to content

Commit 109244c

Browse files
authored
Merge pull request #61161 from xymus/revert-rea-for-api
[Sema] Revert enabling require-explicit-availability for public modules by default
2 parents 453fd22 + a92e607 commit 109244c

8 files changed

+7
-21
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
729729
diagLevel);
730730
}
731731
} else if (Args.getLastArg(OPT_require_explicit_availability,
732-
OPT_require_explicit_availability_target) ||
733-
Opts.LibraryLevel == LibraryLevel::API) {
732+
OPT_require_explicit_availability_target)) {
734733
Opts.RequireExplicitAvailability = DiagnosticBehavior::Warning;
735734
}
736735

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,7 @@ function(_compile_swift_files
483483
# The standard library and overlays are built resiliently when SWIFT_STDLIB_STABLE_ABI=On.
484484
if(SWIFTFILE_IS_STDLIB AND SWIFT_STDLIB_STABLE_ABI)
485485
list(APPEND swift_flags "-enable-library-evolution")
486-
list(APPEND swift_flags "-library-level" "api")
487-
list(APPEND swift_flags "-Xfrontend" "-require-explicit-availability=ignore")
486+
list(APPEND swift_flags "-Xfrontend" "-library-level" "-Xfrontend" "api")
488487
endif()
489488

490489
if("${SWIFT_SDK_${SWIFTFILE_SDK}_THREADING_PACKAGE}" STREQUAL "none")

test/ClangImporter/availability_spi_as_unavailable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1'
1313
public let d: SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
1414

1515
@inlinable
16-
public func inlinableUsingSPI() { // expected-warning{{public declarations should have an availability attribute with an introduction version}}
16+
public func inlinableUsingSPI() {
1717
SharedInterface.foo() // expected-error{{class method 'foo()' cannot be used in an '@inlinable' function because it is an SPI imported from 'SPIContainer'}}
1818
}
1919

test/ClangImporter/availability_spi_as_unavailable_bridging_header.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1'
99
public let d: SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from '__ObjC'}}
1010

1111
@inlinable
12-
public func inlinableUsingSPI() { // expected-warning{{public declarations should have an availability attribute with an introduction version}}
12+
public func inlinableUsingSPI() {
1313
SharedInterface.foo() // expected-error{{class method 'foo()' cannot be used in an '@inlinable' function because it is an SPI imported from '__ObjC'}}
1414
}

test/SPI/spi-only-and-library-level.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public struct LibStruct {}
2525
@_spiOnly import Lib
2626

2727
public func publicClient() -> LibStruct { fatalError() } // expected-error {{cannot use struct 'LibStruct' here; 'Lib' was imported for SPI only}}
28-
// expected-warning @-1 {{public declarations should have an availability attribute with an introduction version}}
2928
@_spi(X) public func spiClient() -> LibStruct { fatalError() }
3029

3130
//--- SPILib.swift

test/Sema/spi-available-inline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class MacOSSPIClass { public init() {} }
1010
@available(macOS 10.4, *)
1111
public class iOSSPIClass { public init() {} }
1212

13-
@inlinable public func foo() { // expected-warning{{public declarations should have an availability attribute with an introduction version}}
13+
@inlinable public func foo() {
1414
_ = MacOSSPIClass() // expected-error {{class 'MacOSSPIClass' cannot be used in an '@inlinable' function because it is SPI}}
1515
_ = iOSSPIClass()
1616
}

test/attr/attr_inlinable_available.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
// Check that `-library-level api` implies `-target-min-inlining-version min`
17-
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple -library-level api -require-explicit-availability=ignore
17+
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple -library-level api
1818

1919

2020
// Check that these rules are only applied when requested and that at least some
@@ -24,7 +24,7 @@
2424

2525
// Check that -target-min-inlining-version overrides -library-level, allowing
2626
// library owners to disable this behavior for API libraries if needed.
27-
// RUN: not %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple -target-min-inlining-version target -library-level api -require-explicit-availability=ignore 2>&1 | %FileCheck --check-prefix NON_MIN %s
27+
// RUN: not %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple -target-min-inlining-version target -library-level api 2>&1 | %FileCheck --check-prefix NON_MIN %s
2828

2929

3030
// Check that we respect -target-min-inlining-version by cranking it up high

test/attr/require_explicit_availability.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@
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-
2413
/// Upgrade the diagnostic to an error.
2514
// RUN: sed -e "s/xpected-warning/xpected-error/" < %s > %t/Errors.swift
2615
// RUN: %target-swift-frontend -typecheck -parse-as-library -verify %t/Errors.swift \

0 commit comments

Comments
 (0)