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

Reordering @preconcurrency imports should be suppressed even if they're in #if conditions #826

Open
saagarjha opened this issue Sep 30, 2024 · 3 comments

Comments

@saagarjha
Copy link

@preconcurrency imports need to come before future modules that also export them (without @preconcurrency). swift-format avoids reordering these, except if they are behind compiler guards. In particular:

#if canImport(Glibc)
@preconcurrency import Glibc
#endif
import Foundation

When formatting, swift-format will move Foundation first:

import Foundation

#if canImport(Glibc)
@preconcurrency import Glibc
#endif

This breaks the effect of @preconcurrency, so we shouldn't do this transformation.

@ahoppen
Copy link
Member

ahoppen commented Sep 30, 2024

Synced to Apple’s issue tracker as rdar://136999610

@ahoppen
Copy link
Member

ahoppen commented Oct 2, 2024

I don’t think the order of imports should matter for anything. Would you mind also filing an issue to https://github.com/swiftlang/swift/issues/new/choose with an example where the import order does matter?

@saagarjha
Copy link
Author

Ok, filed as swiftlang/swift#76842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants