Skip to content

InternalImportsByDefault issue on Swift 6.0 Toolchain #81248

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

Open
Kyle-Ye opened this issue May 2, 2025 · 0 comments
Open

InternalImportsByDefault issue on Swift 6.0 Toolchain #81248

Kyle-Ye opened this issue May 2, 2025 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@Kyle-Ye
Copy link
Contributor

Kyle-Ye commented May 2, 2025

InternalImportsByDefault is a feature flag which can be opt-in since Swift 5.9.

And I just noticed it has some strange bug behavior occurring on Swift 6.0 toolchain.

Description

If you enable InternalImportsByDefault as a upcoming feature, you will be able to use other package's package API even you are not in the same package.

Example 1:
We have Demo and DemoKit package, and Demo has a dependency on DemoKit.

Both Demo and DemoKit is build by Swift 6.0 compiler with Swift 5/6 mode does not matter.

It will be buildable that Demo use DemoKit's package API if we are using Xcode 16.0 with Swift 6.0 compiler.

Example 2:

The same thing applies for the system framework.

SwiftUI.framework & SwiftUICore.framework has some @inlinable package API in its public interface.

We can also call it directly on Demo package if we enable InternalImportsByDefault and compile it under Xcode 16.0 with Swift 6.0 compiiler.

// SwiftUICore.swiftmodule
extension CoreFoundation.CGSize {
  @available(iOS 18.0, macOS 15.0, tvOS 18.0, watchOS 11.0, visionOS 2.0, *)
  @inlinable package var hasZero: Swift.Bool {
    get { width == 0.0 || height == 0.0 }
  }
}
import SwiftUI
let size = CGSize()
print(size.hasZero)

Image

Reproduction

Demo.zip

See Demo package in the attachment.

Expected behavior

Not able to call package API in other package and fail to compile.

Environment

swiftc -version
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0

Additional information

The bug seem to be fixed on Swift 6.1 / Xcode 16.3.

But I did not find any existing issue or test case covering it in the Swift repo.

cc @xymus

@Kyle-Ye Kyle-Ye added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant