Skip to content

Commit

Permalink
Fix Swift 6 warnings (#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgriselli authored Dec 29, 2024
1 parent 681e320 commit 1aa7e28
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
13 changes: 11 additions & 2 deletions Sources/ProjectSpec/Decoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ extension Dictionary where Key: JSONKey {
let keys = Array(dictionary.keys)
var itemResults: [Result<T, Error>] = Array(repeating: .failure(defaultError), count: keys.count)
itemResults.withUnsafeMutableBufferPointer { buffer in
let bufferWrapper = BufferWrapper(buffer: buffer)
DispatchQueue.concurrentPerform(iterations: dictionary.count) { idx in
do {
let key = keys[idx]
let jsonDictionary: JSONDictionary = try dictionary.json(atKeyPath: .key(key))
let item = try T(name: key, jsonDictionary: jsonDictionary)
buffer[idx] = .success(item)
bufferWrapper.buffer[idx] = .success(item)
} catch {
buffer[idx] = .failure(error)
bufferWrapper.buffer[idx] = .failure(error)
}
}
}
Expand Down Expand Up @@ -49,6 +50,14 @@ extension Dictionary where Key: JSONKey {
}
}

private final class BufferWrapper<T>: @unchecked Sendable {
var buffer: UnsafeMutableBufferPointer<T>

init(buffer: UnsafeMutableBufferPointer<T>) {
self.buffer = buffer
}
}

public protocol NamedJSONDictionaryConvertible {

init(name: String, jsonDictionary: JSONDictionary) throws
Expand Down
4 changes: 2 additions & 2 deletions Sources/ProjectSpec/Scheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ extension Scheme.Build: JSONEncodable {
}
}

extension BuildType: JSONPrimitiveConvertible {
extension BuildType: JSONUtilities.JSONPrimitiveConvertible {

public typealias JSONType = String

Expand Down Expand Up @@ -910,7 +910,7 @@ extension BuildType: JSONEncodable {
}
}

extension XCScheme.EnvironmentVariable: JSONObjectConvertible {
extension XCScheme.EnvironmentVariable: JSONUtilities.JSONObjectConvertible {
public static let enabledDefault = true

private static func parseValue(_ value: Any) -> String {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/SwiftPackage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extension SwiftPackage: JSONEncodable {
}
}

extension SwiftPackage.VersionRequirement: JSONObjectConvertible {
extension SwiftPackage.VersionRequirement: JSONUtilities.JSONObjectConvertible {

public init(jsonDictionary: JSONDictionary) throws {
if jsonDictionary["exactVersion"] != nil {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/VersionExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import Version

extension Version: ExpressibleByStringLiteral {
extension Version: Swift.ExpressibleByStringLiteral {

public static func parse(_ string: String) throws -> Version {
if let version = Version(tolerant: string) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGenCLI/Arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import PathKit
import SwiftCLI

extension Path: ConvertibleFromString {
extension Path: SwiftCLI.ConvertibleFromString {

public init?(input: String) {
self.init(input)
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGenKit/CarthageVersionLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct CarthageVersionFile: Decodable {
}
}

extension Platform: CodingKey {
extension Platform: Swift.CodingKey {

public var stringValue: String {
carthageName
Expand Down

0 comments on commit 1aa7e28

Please sign in to comment.