Skip to content
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

[swift] Fix Swift 6 warnings #1513

Merged
merged 2 commits into from
Dec 29, 2024
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
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