Skip to content

Commit 4a6da2d

Browse files
Add support for Swift 6 (#61)
1 parent d2ed6b5 commit 4a6da2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+183
-172
lines changed

.circleci/config.pkl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs {
125125
["test-pkl-\(distribution.normalizedVersion)"] {
126126
docker {
127127
new {
128-
image = "swift:5.10-rhel-ubi9"
128+
image = "swift:6.1-rhel-ubi9"
129129
}
130130
}
131131
resource_class = "xlarge"
@@ -163,7 +163,7 @@ jobs {
163163
["test-format"] {
164164
docker {
165165
new {
166-
image = "swift:5.10-rhel-ubi9"
166+
image = "swift:6.1-rhel-ubi9"
167167
}
168168
}
169169
steps {
@@ -197,7 +197,7 @@ jobs {
197197
["pkl-gen-swift-linux-\(arch)"] {
198198
docker {
199199
new {
200-
image = "swift:5.10-rhel-ubi9"
200+
image = "swift:6.1-rhel-ubi9"
201201
}
202202
}
203203
resource_class = if (arch == "amd64") "xlarge" else "arm.xlarge"

.circleci/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
path: .out/test-results/
2525
resource_class: xlarge
2626
docker:
27-
- image: swift:5.10-rhel-ubi9
27+
- image: swift:6.1-rhel-ubi9
2828
test-pkl-0-29-0:
2929
steps:
3030
- checkout
@@ -52,7 +52,7 @@ jobs:
5252
path: .out/test-results/
5353
resource_class: xlarge
5454
docker:
55-
- image: swift:5.10-rhel-ubi9
55+
- image: swift:6.1-rhel-ubi9
5656
test-license-headers:
5757
steps:
5858
- checkout
@@ -66,7 +66,7 @@ jobs:
6666
- run:
6767
command: make swiftformat-lint
6868
docker:
69-
- image: swift:5.10-rhel-ubi9
69+
- image: swift:6.1-rhel-ubi9
7070
pkl-gen-swift-macos:
7171
steps:
7272
- checkout
@@ -98,7 +98,7 @@ jobs:
9898
- out/
9999
resource_class: arm.xlarge
100100
docker:
101-
- image: swift:5.10-rhel-ubi9
101+
- image: swift:6.1-rhel-ubi9
102102
pkl-gen-swift-linux-amd64:
103103
steps:
104104
- checkout
@@ -114,7 +114,7 @@ jobs:
114114
- out/
115115
resource_class: xlarge
116116
docker:
117-
- image: swift:5.10-rhel-ubi9
117+
- image: swift:6.1-rhel-ubi9
118118
pkl-package:
119119
steps:
120120
- checkout

DEVELOPMENT.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ make format
2828
swiftformat .
2929
3030
hawkeye format
31-
----
31+
----
32+
33+
To regenerate all the test fixtures after changes to the codegen run `make generate-fixtures`.

Package.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.10
1+
// swift-tools-version: 6.0
22
//===----------------------------------------------------------------------===//
33
// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
44
//
@@ -49,28 +49,33 @@ let package = Package(
4949
targets: [
5050
.target(
5151
name: "PklSwift",
52-
dependencies: ["MessagePack", "PklSwiftInternals", "SemanticVersion"]
52+
dependencies: ["MessagePack", "PklSwiftInternals", "SemanticVersion"],
53+
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
5354
),
5455
.target(
55-
name: "PklSwiftInternals"
56+
name: "PklSwiftInternals",
57+
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
5658
),
5759
.target(
5860
name: "MessagePack",
5961
dependencies: [
6062
.product(name: "SystemPackage", package: "swift-system"),
61-
]
63+
],
64+
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
6265
),
6366
.executableTarget(
6467
name: "pkl-gen-swift",
6568
dependencies: [
6669
.product(name: "ArgumentParser", package: "swift-argument-parser"),
6770
"PklSwift",
6871
],
69-
resources: [.embedInCode("Resources/VERSION.txt")]
72+
resources: [.embedInCode("Resources/VERSION.txt")],
73+
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
7074
),
7175
.executableTarget(
7276
name: "test-external-reader",
73-
dependencies: ["PklSwift"]
77+
dependencies: ["PklSwift"],
78+
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
7479
),
7580
.testTarget(
7681
name: "PklSwiftTests",
@@ -87,14 +92,17 @@ let package = Package(
8792
"Fixtures/Collections.pkl",
8893
"Fixtures/Poly.pkl",
8994
"Fixtures/ApiTypes.pkl",
90-
]
95+
],
96+
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
9197
),
9298
.testTarget(
9399
name: "MessagePackTests",
94100
dependencies: [
95101
"MessagePack",
96-
]
102+
],
103+
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
97104
),
98105
],
106+
swiftLanguageModes: [.v5, .v6],
99107
cxxLanguageStandard: .cxx20
100108
)

Sources/MessagePack/Decoder/MessagePackDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public final class MessagePackDecoder {
417417
}
418418

419419
/// A generic representation of MessagePack values.
420-
public enum MessagePackValue {
420+
public enum MessagePackValue: @unchecked Sendable {
421421
case `nil`
422422
case bool(Bool)
423423
case int(any BinaryInteger)

Sources/MessagePack/Decoder/SingleValueDecodingContainer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
9292
}
9393
}
9494

95-
func decode(_: Date.Type) throws -> Date {
95+
private func decode(_: Date.Type) throws -> Date {
9696
switch value {
9797
case .timestamp(let value):
9898
return value
@@ -101,7 +101,7 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
101101
}
102102
}
103103

104-
func decode(_: Data.Type) throws -> Data {
104+
private func decode(_: Data.Type) throws -> Data {
105105
switch value {
106106
case .bin(let value):
107107
return Data(value)
@@ -110,7 +110,7 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
110110
}
111111
}
112112

113-
func decode(_: [UInt8].Type) throws -> [UInt8] {
113+
private func decode(_: [UInt8].Type) throws -> [UInt8] {
114114
// accept either msgpack binary or array
115115
switch value {
116116
case .bin(let value):
@@ -130,7 +130,7 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
130130
}
131131
}
132132

133-
func decode(_: URL.Type) throws -> URL {
133+
private func decode(_: URL.Type) throws -> URL {
134134
switch value {
135135
case .string(let value):
136136
if let url = URL(string: value) {

Sources/MessagePack/Encoder/SingleValueEncodingContainer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ extension _MessagePackEncoder.SingleValueContainer: SingleValueEncodingContainer
219219
self.storage.append(contentsOf: value.bytes)
220220
}
221221

222-
func encode(_ value: Date) throws {
222+
private func encode(_ value: Date) throws {
223223
try checkCanEncode(value: value)
224224
defer { self.canEncodeNewValue = false }
225225

@@ -246,7 +246,7 @@ extension _MessagePackEncoder.SingleValueContainer: SingleValueEncodingContainer
246246
}
247247
}
248248

249-
func encode(_ value: Data) throws {
249+
private func encode(_ value: Data) throws {
250250
let length = value.count
251251
if let uint8 = UInt8(exactly: length) {
252252
self.storage.append(0xC4)
@@ -269,7 +269,7 @@ extension _MessagePackEncoder.SingleValueContainer: SingleValueEncodingContainer
269269
}
270270
}
271271

272-
func encode(_ value: [UInt8]) throws {
272+
private func encode(_ value: [UInt8]) throws {
273273
let length = value.count
274274
if let uint8 = UInt8(exactly: length) {
275275
self.storage.append(0xC4)
@@ -292,7 +292,7 @@ extension _MessagePackEncoder.SingleValueContainer: SingleValueEncodingContainer
292292
}
293293
}
294294

295-
func encode(_ value: URL) throws {
295+
private func encode(_ value: URL) throws {
296296
try self.encode(value.absoluteString)
297297
}
298298

Sources/MessagePack/IO.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public protocol Reader {
4141
}
4242

4343
/// Writes bytes into an internal buffer.
44-
public class BufferWriter: Writer {
44+
public class BufferWriter: Writer, @unchecked Sendable {
4545
var bytes: [UInt8] = []
4646

4747
public func write(_ buffer: UnsafeRawBufferPointer) throws {
@@ -54,7 +54,7 @@ public class BufferWriter: Writer {
5454
}
5555

5656
/// Reads bytes from the provided buffer.
57-
public class BufferReader: Reader {
57+
public class BufferReader: Reader, @unchecked Sendable {
5858
let bytes: [UInt8]
5959
var index: Int
6060

@@ -81,7 +81,7 @@ public class BufferReader: Reader {
8181
}
8282

8383
/// Like [Reader], but also supports a way to peek bytes.
84-
class PeekableReader: Reader {
84+
class PeekableReader: Reader, @unchecked Sendable {
8585
var peekedByte: UInt8?
8686

8787
let reader: Reader

Sources/PklSwift/API/DataSize.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818
import MessagePack
1919

2020
/// DataSize is the Swift representation of Pkl's `pkl.DataSize`.
21-
public struct DataSize: Hashable {
21+
public struct DataSize: Hashable, Sendable {
2222
/// The value of this ``DataSize`` in the unit set in ``unit``.
2323
let value: Float64
2424

@@ -150,7 +150,7 @@ extension DataSize {
150150
}
151151

152152
/// The unit of a ``DataSize``.
153-
public enum DataSizeUnit: String, CaseIterable, Decodable {
153+
public enum DataSizeUnit: String, CaseIterable, Decodable, Sendable {
154154
/// byte
155155
case b
156156

Sources/PklSwift/API/Duration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Foundation
1818

1919
/// Duration is the Swift representation of Pkl's `pkl.Duration`.
20-
public struct Duration: Hashable {
20+
public struct Duration: Hashable, Sendable {
2121
/// The value of this ``Duration`` in the unit set in ``unit``.
2222
public let value: Float64
2323

@@ -137,7 +137,7 @@ extension Duration {
137137
}
138138

139139
/// A unit (magnitude) of duration.
140-
public enum DurationUnit: String, CaseIterable, Decodable {
140+
public enum DurationUnit: String, CaseIterable, Decodable, Sendable {
141141
/// Nanosecond
142142
case ns
143143

0 commit comments

Comments
 (0)