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 6 snapshot fixes #252

Merged
merged 3 commits into from
Jul 26, 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
23 changes: 20 additions & 3 deletions Sources/Dependencies/DependencyValues/Calendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,28 @@ extension DependencyValues {
/// // Make assertions with model...
/// ```
public var calendar: Calendar {
get { self[CalendarKey.self] }
set { self[CalendarKey.self] = newValue }
get {
#if canImport(Darwin)
self[CalendarKey.self]
#else
self[CalendarKey.self].wrappedValue
#endif
}
set {
#if canImport(Darwin)
self[CalendarKey.self] = newValue
#else
self[CalendarKey.self].wrappedValue = newValue
#endif
}
}

private enum CalendarKey: DependencyKey {
static let liveValue = Calendar.autoupdatingCurrent
#if canImport(Darwin)
static let liveValue = Calendar.autoupdatingCurrent
#else
// NB: 'Calendar' sendability is not yet available in a 'swift-corelibs-foundation' release
static let liveValue = UncheckedSendable(Calendar.autoupdatingCurrent)
#endif
}
}
23 changes: 20 additions & 3 deletions Sources/Dependencies/DependencyValues/Locale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,28 @@ extension DependencyValues {
/// // Make assertions with model...
/// ```
public var locale: Locale {
get { self[LocaleKey.self] }
set { self[LocaleKey.self] = newValue }
get {
#if canImport(Darwin)
self[LocaleKey.self]
#else
self[LocaleKey.self].wrappedValue
#endif
}
set {
#if canImport(Darwin)
self[LocaleKey.self] = newValue
#else
self[LocaleKey.self].wrappedValue = newValue
#endif
}
}

private enum LocaleKey: DependencyKey {
static let liveValue = Locale.autoupdatingCurrent
#if canImport(Darwin)
static let liveValue = Locale.autoupdatingCurrent
#else
// NB: 'Locale' sendability is not yet available in a 'swift-corelibs-foundation' release
static let liveValue = UncheckedSendable(Locale.autoupdatingCurrent)
#endif
}
}
23 changes: 20 additions & 3 deletions Sources/Dependencies/DependencyValues/TimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,28 @@ extension DependencyValues {
/// // Make assertions with model...
/// ```
public var timeZone: TimeZone {
get { self[TimeZoneKey.self] }
set { self[TimeZoneKey.self] = newValue }
get {
#if canImport(Darwin)
self[TimeZoneKey.self]
#else
self[TimeZoneKey.self].wrappedValue
#endif
}
set {
#if canImport(Darwin)
self[TimeZoneKey.self] = newValue
#else
self[TimeZoneKey.self].wrappedValue = newValue
#endif
}
}

private enum TimeZoneKey: DependencyKey {
static let liveValue = TimeZone.autoupdatingCurrent
#if canImport(Darwin)
static let liveValue = TimeZone.autoupdatingCurrent
#else
// NB: 'TimeZone' sendability is not yet available in a 'swift-corelibs-foundation' release
static let liveValue = UncheckedSendable(TimeZone.autoupdatingCurrent)
#endif
}
}
6 changes: 3 additions & 3 deletions Sources/Dependencies/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extension DependencyValues {
}

@available(*, deprecated, message: "Use 'withDependencies' instead.")
public static func withValue<Value, R>(
public static func withValue<Value, R: Sendable>(
_ keyPath: WritableKeyPath<DependencyValues, Value>,
_ value: @autoclosure () -> Value,
operation: () async throws -> R
Expand All @@ -133,7 +133,7 @@ extension DependencyValues {
}

@available(*, deprecated, message: "Use 'withDependencies' instead.")
public static func withValues<R>(
public static func withValues<R: Sendable>(
_ updateValuesForOperation: (inout Self) throws -> Void,
operation: () async throws -> R
) async rethrows -> R {
Expand All @@ -149,7 +149,7 @@ extension DependencyValues {
}

@available(*, deprecated, message: "Use 'withDependencies' instead.")
public static func withTestValues<R>(
public static func withTestValues<R: Sendable>(
_ updateValuesForOperation: (inout Self) async throws -> Void,
assert operation: () async throws -> R
) async rethrows -> R {
Expand Down
Loading