Skip to content

Commit

Permalink
(113200224) JSON/PropertyList coders userInfo should require Sendable…
Browse files Browse the repository at this point in the history
… values
  • Loading branch information
jmschonfeld committed Aug 21, 2024
1 parent e34e1c9 commit c93635f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/JSON/JSONDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ open class JSONDecoder {
}

/// Contextual user-provided information for use during decoding.
open var userInfo: [CodingUserInfoKey : Any] {
@preconcurrency
open var userInfo: [CodingUserInfoKey : any Sendable] {
get {
optionsLock.lock()
defer { optionsLock.unlock() }
Expand Down Expand Up @@ -309,7 +310,7 @@ open class JSONDecoder {
var dataDecodingStrategy: DataDecodingStrategy = .base64
var nonConformingFloatDecodingStrategy: NonConformingFloatDecodingStrategy = .throw
var keyDecodingStrategy: KeyDecodingStrategy = .useDefaultKeys
var userInfo: [CodingUserInfoKey : Any] = [:]
var userInfo: [CodingUserInfoKey : any Sendable] = [:]
var json5: Bool = false
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/JSON/JSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ open class JSONEncoder {
}

/// Contextual user-provided information for use during encoding.
open var userInfo: [CodingUserInfoKey : Any] {
@preconcurrency
open var userInfo: [CodingUserInfoKey : any Sendable] {
get {
optionsLock.lock()
defer { optionsLock.unlock() }
Expand Down Expand Up @@ -324,7 +325,7 @@ open class JSONEncoder {
var dataEncodingStrategy: DataEncodingStrategy = .base64
var nonConformingFloatEncodingStrategy: NonConformingFloatEncodingStrategy = .throw
var keyEncodingStrategy: KeyEncodingStrategy = .useDefaultKeys
var userInfo: [CodingUserInfoKey : Any] = [:]
var userInfo: [CodingUserInfoKey : any Sendable] = [:]
}

/// The options set on the top-level encoder.
Expand Down
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/PropertyList/PlistDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ open class PropertyListDecoder {
// MARK: Options

/// Contextual user-provided information for use during decoding.
open var userInfo: [CodingUserInfoKey : Any] {
@preconcurrency
open var userInfo: [CodingUserInfoKey : any Sendable] {
get {
optionsLock.lock()
defer { optionsLock.unlock() }
Expand All @@ -62,7 +63,7 @@ open class PropertyListDecoder {

/// Options set on the top-level encoder to pass down the decoding hierarchy.
internal struct _Options {
var userInfo: [CodingUserInfoKey : Any] = [:]
var userInfo: [CodingUserInfoKey : any Sendable] = [:]
}

/// The options set on the top-level decoder.
Expand Down
5 changes: 3 additions & 2 deletions Sources/FoundationEssentials/PropertyList/PlistEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ open class PropertyListEncoder {
}

/// Contextual user-provided information for use during encoding.
open var userInfo: [CodingUserInfoKey : Any] {
@preconcurrency
open var userInfo: [CodingUserInfoKey : any Sendable] {
get {
optionsLock.lock()
defer { optionsLock.unlock() }
Expand All @@ -74,7 +75,7 @@ open class PropertyListEncoder {
/// Options set on the top-level encoder to pass down the encoding hierarchy.
internal struct _Options {
var outputFormat: PropertyListDecoder.PropertyListFormat = .binary
var userInfo: [CodingUserInfoKey : Any] = [:]
var userInfo: [CodingUserInfoKey : any Sendable] = [:]
}

/// The options set on the top-level encoder.
Expand Down

0 comments on commit c93635f

Please sign in to comment.