Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable AccessLevelOnImport by default #1413

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions swift/toolchains/swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,14 @@ def _swift_toolchain_impl(ctx):
target_triple = target_triple,
))

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",
])

requested_features.extend(ctx.features)

# Swift.org toolchains assume everything is just available on the PATH so we
Expand Down
8 changes: 8 additions & 0 deletions swift/toolchains/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,14 @@ def _xcode_swift_toolchain_impl(ctx):
target_triple = target_triple,
))

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",
])

if _is_xcode_at_least_version(xcode_config, "14.3"):
requested_features.append(SWIFT_FEATURE__SUPPORTS_UPCOMING_FEATURES)

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 @@ -18,7 +18,7 @@ import ToyModule
struct Main {
static func main() {
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