Skip to content
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
4 changes: 1 addition & 3 deletions Package@swift-5.8.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
15 changes: 10 additions & 5 deletions Sources/ArgumentParser/Parsable Properties/CompletionKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}

Expand Down Expand Up @@ -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.
///
Expand Down
12 changes: 8 additions & 4 deletions Sources/ArgumentParser/Parsing/CommandParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -557,8 +561,8 @@ private func asyncCustomCompletions(

semaphore.wait()
return completionsBox.withLock { $0 }
#endif
}
#endif

// MARK: Building Command Stacks

Expand Down
7 changes: 7 additions & 0 deletions Sources/ArgumentParser/Utilities/Mutex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading