diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift index fb860aff1..9b4d0aa6c 100644 --- a/Package@swift-5.8.swift +++ b/Package@swift-5.8.swift @@ -146,9 +146,7 @@ for target in package.targets { // https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md settings.append(.enableUpcomingFeature("MemberImportVisibility")) target.swiftSettings = settings - case .macro, .plugin, .system, .binary: + default: break // not applicable - @unknown default: - break // we don't know what to do here, do nothing } } diff --git a/Sources/ArgumentParser/Parsable Properties/CompletionKind.swift b/Sources/ArgumentParser/Parsable Properties/CompletionKind.swift index 97573656c..a7a069d77 100644 --- a/Sources/ArgumentParser/Parsable Properties/CompletionKind.swift +++ b/Sources/ArgumentParser/Parsable Properties/CompletionKind.swift @@ -43,8 +43,10 @@ public struct CompletionKind { case custom(@Sendable ([String], Int, String) -> [String]) #if !canImport(Dispatch) @available(*, unavailable, message: "DispatchSemaphore is unavailable") - #endif case customAsync(@Sendable ([String], Int, String) async -> [String]) + #else + case customAsync(@Sendable ([String], Int, String) async -> [String]) + #endif case customDeprecated(@Sendable ([String]) -> [String]) } @@ -186,17 +188,20 @@ public struct CompletionKind { /// except that the closure is asynchronous. #if !canImport(Dispatch) @available(*, unavailable, message: "DispatchSemaphore is unavailable") - #endif @available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) public static func custom( _ completion: @Sendable @escaping ([String], Int, String) async -> [String] ) -> CompletionKind { - #if !canImport(Dispatch) fatalError("DispatchSemaphore is unavailable") - #else + } + #else + @available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) + public static func custom( + _ completion: @Sendable @escaping ([String], Int, String) async -> [String] + ) -> CompletionKind { CompletionKind(kind: .customAsync(completion)) - #endif } + #endif /// Deprecated; only kept for backwards compatibility. /// diff --git a/Sources/ArgumentParser/Parsing/CommandParser.swift b/Sources/ArgumentParser/Parsing/CommandParser.swift index b3296d675..81ad49441 100644 --- a/Sources/ArgumentParser/Parsing/CommandParser.swift +++ b/Sources/ArgumentParser/Parsing/CommandParser.swift @@ -531,15 +531,19 @@ private func parseCustomCompletionArguments( #if !canImport(Dispatch) @available(*, unavailable, message: "DispatchSemaphore is unavailable") -#endif @available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) private func asyncCustomCompletions( from args: [String], complete: @escaping @Sendable ([String], Int, String) async -> [String] ) throws -> [String] { - #if !canImport(Dispatch) throw ParserError.invalidState - #else +} +#else +@available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) +private func asyncCustomCompletions( + from args: [String], + complete: @escaping @Sendable ([String], Int, String) async -> [String] +) throws -> [String] { let (args, completingArgumentIndex, completingPrefix) = try parseCustomCompletionArguments(from: args) @@ -557,8 +561,8 @@ private func asyncCustomCompletions( semaphore.wait() return completionsBox.withLock { $0 } - #endif } +#endif // MARK: Building Command Stacks diff --git a/Sources/ArgumentParser/Utilities/Mutex.swift b/Sources/ArgumentParser/Utilities/Mutex.swift index 129d0433c..6efb2a55c 100644 --- a/Sources/ArgumentParser/Utilities/Mutex.swift +++ b/Sources/ArgumentParser/Utilities/Mutex.swift @@ -10,10 +10,17 @@ //===----------------------------------------------------------------------===// #if canImport(os) +#if compiler(>=6.0) internal import os #if canImport(C.os.lock) internal import C.os.lock #endif +#else +import os +#if canImport(C.os.lock) +import C.os.lock +#endif +#endif #elseif canImport(Bionic) @preconcurrency import Bionic #elseif canImport(Glibc)