Skip to content

Commit

Permalink
Merge pull request #13 from MFB-Technologies-Inc/strict-concurrency-fix
Browse files Browse the repository at this point in the history
Strict concurrency fix
  • Loading branch information
roanutil authored Jun 13, 2024
2 parents 98f9fd9 + 5d9085e commit ff55e8b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 23 deletions.
27 changes: 12 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ let package = Package(
.library(name: "ArgumentEncoding", targets: ["ArgumentEncoding"]),
],
dependencies: [
.dependencies,
.dependencies(),
],
targets: [
.target(
name: "ArgumentEncoding",
dependencies: [
.dependencies,
.dependencies(),
],
swiftSettings: .swiftSix
),
Expand All @@ -32,25 +32,22 @@ let package = Package(
// MARK: PointFree

extension Package.Dependency {
static let dependencies: Package.Dependency = .package(
url: "https://github.com/pointfreeco/swift-dependencies.git",
.upToNextMajor(from: "1.0.0")
)
static func dependencies() -> Package.Dependency {
.package(
url: "https://github.com/pointfreeco/swift-dependencies.git",
.upToNextMajor(from: "1.0.0")
)
}
}

extension Target.Dependency {
static let dependencies: Self = .product(name: "Dependencies", package: "swift-dependencies")
static func dependencies() -> Self {
.product(name: "Dependencies", package: "swift-dependencies")
}
}

extension [SwiftSetting] {
static let swiftSix: Self = [
.enableUpcomingFeature("BareSlashRegexLiterals"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("DeprecateApplicationMain"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("ImportObjcForwardDeclarations"),
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("StrictConcurrency"),
.enableExperimentalFeature("StrictConcurrency"),
]
}
45 changes: 45 additions & 0 deletions Package@swift-6.0.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// swift-tools-version: 6.0

import PackageDescription

let package = Package(
name: "swift-argument-encoding",
platforms: [.macOS(.v12)],
products: [
.library(name: "ArgumentEncoding", targets: ["ArgumentEncoding"]),
],
dependencies: [
.dependencies(),
],
targets: [
.target(
name: "ArgumentEncoding",
dependencies: [
.dependencies(),
]
),
.testTarget(
name: "ArgumentEncodingTests",
dependencies: [
"ArgumentEncoding",
]
),
]
)

// MARK: PointFree

extension Package.Dependency {
static func dependencies() -> Package.Dependency {
.package(
url: "https://github.com/pointfreeco/swift-dependencies.git",
.upToNextMajor(from: "1.0.0")
)
}
}

extension Target.Dependency {
static func dependencies() -> Self {
.product(name: "Dependencies", package: "swift-dependencies")
}
}
30 changes: 22 additions & 8 deletions Tests/ArgumentEncodingTests/ArgumentGroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,28 @@ final class ArgumentGroupTests: XCTestCase {
}
}

extension Array: ArgumentGroup, FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }
#if swift(>=6)
extension Array: @retroactive ArgumentGroup, @retroactive FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }

public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}
public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}

extension Dictionary: ArgumentGroup, FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }
extension Dictionary: @retroactive ArgumentGroup, @retroactive FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }

public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}
public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}
#else
extension Array: ArgumentGroup, FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }

public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}

extension Dictionary: ArgumentGroup, FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }

public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}
#endif

0 comments on commit ff55e8b

Please sign in to comment.