Skip to content

Commit

Permalink
Enable AccessLevelOnImport by default.
Browse files Browse the repository at this point in the history
This feature also makes it an error for `.swiftinterface` files to publicly import non-resilient modules, so I've updated our `.swiftinterface` test case to stop depending on Foundation, which is not resilient on Linux.

PiperOrigin-RevId: 640123191
  • Loading branch information
allevato authored and swiple-rules-gardener committed Jun 4, 2024
1 parent f235362 commit b5230b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 7 additions & 0 deletions swift/toolchains/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,13 @@ def _xcode_swift_toolchain_impl(ctx):
target_triple = target_triple,
))
requested_features.extend(default_warnings_as_errors_features())
requested_features.extend([
# Allow users to start using access levels on `import`s by default. Note
# that this does *not* change the default access level for `import`s to
# `internal`; that is controlled by the upcoming feature flag
# `InternalImportsByDefault`.
"swift.experimental.AccessLevelOnImport",
])

# TODO: b/336996662 - Use a very high Xcode version number until we've
# confirmed the actual Xcode release that ships with a compiler that
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/module_interface/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
import ToyModule

let value = ToyValue(number: 10)
print(value.hexString)
print(value.stringValue)
print(value.squared())
6 changes: 2 additions & 4 deletions test/fixtures/module_interface/library/ToyModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

/// A toy value.
@frozen
public struct ToyValue {
/// The numeric value.
public var number: Int

/// The hexadecimal value of the numeric value.
public var hexString: String {
String(format: "0x%x", number)
public var stringValue: String {
"\(number)"
}

/// Creates a new toy value with the given numeric value.
Expand Down

1 comment on commit b5230b0

@brentleyjones
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.