Skip to content

Commit 501b609

Browse files
committed
fix more Swift 6 warnings
1 parent 19c910a commit 501b609

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

Tests/OpenAPIKit30Tests/TestHelpers.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
@preconcurrency import Yams
1010
import XCTest
1111

12-
fileprivate let foundationTestEncoder = { () -> JSONEncoder in
12+
fileprivate func foundationTestEncoder() -> JSONEncoder {
1313
let encoder = JSONEncoder()
1414
if #available(macOS 10.13, *) {
1515
encoder.dateEncodingStrategy = .iso8601
@@ -22,25 +22,25 @@ fileprivate let foundationTestEncoder = { () -> JSONEncoder in
2222
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
2323
#endif
2424
return encoder
25-
}()
25+
}
2626

2727
func orderUnstableEncode<T: Encodable>(_ value: T) throws -> Data {
28-
return try foundationTestEncoder.encode(value)
28+
return try foundationTestEncoder().encode(value)
2929
}
3030

3131
func orderUnstableTestStringFromEncoding<T: Encodable>(of entity: T) throws -> String? {
3232
return String(data: try orderUnstableEncode(entity), encoding: .utf8)
3333
}
3434

35-
fileprivate let yamsTestEncoder = { () -> YAMLEncoder in
35+
fileprivate func yamsTestEncoder() -> YAMLEncoder {
3636
return YAMLEncoder()
37-
}()
37+
}
3838

3939
func orderStableYAMLEncode<T: Encodable>(_ value: T) throws -> String {
40-
return try yamsTestEncoder.encode(value)
40+
return try yamsTestEncoder().encode(value)
4141
}
4242

43-
fileprivate func buildFoundationTestDecoder(_ userInfo: [CodingUserInfoKey: Any] = [:]) -> JSONDecoder {
43+
fileprivate func buildFoundationTestDecoder(_ userInfo: [CodingUserInfoKey: any Sendable] = [:]) -> JSONDecoder {
4444
let decoder = JSONDecoder()
4545
decoder.userInfo = userInfo
4646
if #available(macOS 10.12, *) {
@@ -54,18 +54,18 @@ fileprivate func buildFoundationTestDecoder(_ userInfo: [CodingUserInfoKey: Any]
5454
return decoder
5555
}
5656

57-
fileprivate let foundationTestDecoder = { () -> JSONDecoder in buildFoundationTestDecoder() }()
57+
fileprivate func foundationTestDecoder() -> JSONDecoder { buildFoundationTestDecoder() }
5858

59-
func orderUnstableDecode<T: Decodable>(_ type: T.Type, from data: Data, userInfo : [CodingUserInfoKey: Any] = [:]) throws -> T {
59+
func orderUnstableDecode<T: Decodable>(_ type: T.Type, from data: Data, userInfo : [CodingUserInfoKey: any Codable] = [:]) throws -> T {
6060
return try buildFoundationTestDecoder(userInfo).decode(T.self, from: data)
6161
}
6262

63-
fileprivate let yamsTestDecoder = { () -> YAMLDecoder in
63+
fileprivate func yamsTestDecoder() -> YAMLDecoder {
6464
return YAMLDecoder()
65-
}()
65+
}
6666

6767
func orderStableDecode<T: Decodable>(_ type: T.Type, from data: Data) throws -> T {
68-
return try yamsTestDecoder.decode(T.self, from: data)
68+
return try yamsTestDecoder().decode(T.self, from: data)
6969
}
7070

7171
func assertJSONEquivalent(_ str1: String?, _ str2: String?, file: StaticString = #file, line: UInt = #line) {

Tests/OpenAPIKitCoreTests/TestHelpers.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99
import XCTest
1010

11-
fileprivate let foundationTestEncoder = { () -> JSONEncoder in
11+
fileprivate func foundationTestEncoder() -> JSONEncoder {
1212
let encoder = JSONEncoder()
1313
if #available(macOS 10.13, *) {
1414
encoder.dateEncodingStrategy = .iso8601
@@ -21,10 +21,10 @@ fileprivate let foundationTestEncoder = { () -> JSONEncoder in
2121
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
2222
#endif
2323
return encoder
24-
}()
24+
}
2525

2626
func orderUnstableEncode<T: Encodable>(_ value: T) throws -> Data {
27-
return try foundationTestEncoder.encode(value)
27+
return try foundationTestEncoder().encode(value)
2828
}
2929

3030
func orderUnstableTestStringFromEncoding<T: Encodable>(of entity: T) throws -> String? {
@@ -35,7 +35,7 @@ func orderUnstableTestStringFromEncoding<T: Encodable>(of entity: T) throws -> S
3535
// return try fineJSONTestEncoder.encode(value)
3636
//}
3737

38-
fileprivate let foundationTestDecoder = { () -> JSONDecoder in
38+
fileprivate func foundationTestDecoder() -> JSONDecoder {
3939
let decoder = JSONDecoder()
4040
if #available(macOS 10.12, *) {
4141
decoder.dateDecodingStrategy = .iso8601
@@ -46,10 +46,10 @@ fileprivate let foundationTestDecoder = { () -> JSONDecoder in
4646
decoder.keyDecodingStrategy = .useDefaultKeys
4747
#endif
4848
return decoder
49-
}()
49+
}
5050

5151
func orderUnstableDecode<T: Decodable>(_ type: T.Type, from data: Data) throws -> T {
52-
return try foundationTestDecoder.decode(T.self, from: data)
52+
return try foundationTestDecoder().decode(T.self, from: data)
5353
}
5454

5555
//func orderStableDecode<T: Decodable>(_ type: T.Type, from data: Data) throws -> T {

Tests/OpenAPIKitTests/TestHelpers.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
@preconcurrency import Yams
1010
import XCTest
1111

12-
fileprivate let foundationTestEncoder = { () -> JSONEncoder in
12+
fileprivate func foundationTestEncoder() -> JSONEncoder {
1313
let encoder = JSONEncoder()
1414
if #available(macOS 10.13, *) {
1515
encoder.dateEncodingStrategy = .iso8601
@@ -22,25 +22,25 @@ fileprivate let foundationTestEncoder = { () -> JSONEncoder in
2222
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
2323
#endif
2424
return encoder
25-
}()
25+
}
2626

2727
func orderUnstableEncode<T: Encodable>(_ value: T) throws -> Data {
28-
return try foundationTestEncoder.encode(value)
28+
return try foundationTestEncoder().encode(value)
2929
}
3030

3131
func orderUnstableTestStringFromEncoding<T: Encodable>(of entity: T) throws -> String? {
3232
return String(data: try orderUnstableEncode(entity), encoding: .utf8)
3333
}
3434

35-
fileprivate let yamsTestEncoder = { () -> YAMLEncoder in
35+
fileprivate func yamsTestEncoder() -> YAMLEncoder {
3636
return YAMLEncoder()
37-
}()
37+
}
3838

3939
func orderStableYAMLEncode<T: Encodable>(_ value: T) throws -> String {
40-
return try yamsTestEncoder.encode(value)
40+
return try yamsTestEncoder().encode(value)
4141
}
4242

43-
fileprivate func buildFoundationTestDecoder(_ userInfo: [CodingUserInfoKey: Any] = [:]) -> JSONDecoder {
43+
fileprivate func buildFoundationTestDecoder(_ userInfo: [CodingUserInfoKey: any Sendable] = [:]) -> JSONDecoder {
4444
let decoder = JSONDecoder()
4545
decoder.userInfo = userInfo
4646
if #available(macOS 10.12, *) {
@@ -54,18 +54,18 @@ fileprivate func buildFoundationTestDecoder(_ userInfo: [CodingUserInfoKey: Any]
5454
return decoder
5555
}
5656

57-
fileprivate let foundationTestDecoder = { () -> JSONDecoder in buildFoundationTestDecoder() }()
57+
fileprivate func foundationTestDecoder() -> JSONDecoder { buildFoundationTestDecoder() }
5858

59-
func orderUnstableDecode<T: Decodable>(_ type: T.Type, from data: Data, userInfo : [CodingUserInfoKey: Any] = [:]) throws -> T {
59+
func orderUnstableDecode<T: Decodable>(_ type: T.Type, from data: Data, userInfo : [CodingUserInfoKey: any Sendable] = [:]) throws -> T {
6060
return try buildFoundationTestDecoder(userInfo).decode(T.self, from: data)
6161
}
6262

63-
fileprivate let yamsTestDecoder = { () -> YAMLDecoder in
63+
fileprivate func yamsTestDecoder() -> YAMLDecoder {
6464
return YAMLDecoder()
65-
}()
65+
}
6666

6767
func orderStableDecode<T: Decodable>(_ type: T.Type, from data: Data) throws -> T {
68-
return try yamsTestDecoder.decode(T.self, from: data)
68+
return try yamsTestDecoder().decode(T.self, from: data)
6969
}
7070

7171
func assertJSONEquivalent(_ str1: String?, _ str2: String?, file: StaticString = #file, line: UInt = #line) {

0 commit comments

Comments
 (0)