Skip to content

Add two Sendable annotations to enable building SourceKit-LSP in Swift 6 mode #7559

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

Merged
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: 3 additions & 5 deletions Sources/PackageLoading/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,21 @@ private func isAndroid() -> Bool {
(try? localFileSystem.isFile(AbsolutePath(validating: "/system/bin/toybox"))) ?? false
}

public enum Platform: Equatable {
public enum Platform: Equatable, Sendable {
case android
case darwin
case linux(LinuxFlavor)
case windows

/// Recognized flavors of linux.
public enum LinuxFlavor: Equatable {
public enum LinuxFlavor: Equatable, Sendable {
case debian
case fedora
}
}

extension Platform {
// This is not just a computed property because the ToolchainRegistryTests
// change the value.
Comment on lines -37 to -38
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this comment wasn't true 😅? If that's the case though, can it just be a computed property?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was, ToolchainRegistryTests is in SourceKit-LSP: swiftlang/sourcekit-lsp#1276 (comment)

I prefer it to be stored so we don’t re-run uname every time the variable is accessed.

public static var current: Platform? = {
public static let current: Platform? = {
#if os(Windows)
return .windows
#else
Expand Down
2 changes: 1 addition & 1 deletion Sources/PackageLoading/TargetSourcesBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public struct TargetSourcesBuilder {
}

/// Describes a rule for including a source or resource file in a target.
public struct FileRuleDescription {
public struct FileRuleDescription: Sendable {
Copy link
Contributor

@giginet giginet May 15, 2024

Choose a reason for hiding this comment

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

Don't we need FileRuleDescription.Rule to conform to Sendable?
Because it is public.

Copy link
Member Author

Choose a reason for hiding this comment

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

This change is trying to be minimal to get SourceKit-LSP building in Swift 6 mode. Adding proper Sendable annotations to SwiftPM wherever sensible is not a goal of this PR.

/// A rule semantically describes a file/directory in a target.
///
/// It is up to the build system to translate a rule into a build command.
Expand Down