Skip to content

Commit 8b5ceda

Browse files
committed
Mark static properties in JSONReference as nonisolated(unsafe)
1 parent 99433ce commit 8b5ceda

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Sources/SwiftCompilerPluginMessageHandling/JSON/JSONEncoding.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func encodeToJSON(value: some Encodable) throws -> [UInt8] {
1717
}
1818

1919
/// Intermediate representation for serializing JSON structure.
20-
private class JSONReference {
20+
private final class JSONReference {
2121
enum Backing {
2222
case null
2323
case trueKeyword
@@ -60,9 +60,11 @@ private class JSONReference {
6060
backing = .array(arr)
6161
}
6262

63-
static let null: JSONReference = .init(backing: .null)
64-
static let trueKeyword: JSONReference = .init(backing: .trueKeyword)
65-
static let falseKeyword: JSONReference = .init(backing: .falseKeyword)
63+
// nonisolated(unsafe) is fine for these properties because they represent primitives
64+
// that are never modified.
65+
nonisolated(unsafe) static let null: JSONReference = .init(backing: .null)
66+
nonisolated(unsafe) static let trueKeyword: JSONReference = .init(backing: .trueKeyword)
67+
nonisolated(unsafe) static let falseKeyword: JSONReference = .init(backing: .falseKeyword)
6668

6769
@inline(__always)
6870
static func newArray() -> JSONReference {

0 commit comments

Comments
 (0)