Use explicit `any` (#180)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
This commit is contained in:
parent
d8a954e69f
commit
5c6d5bfaf0
|
@ -209,7 +209,7 @@ Manages `Defaults.Keys` between the locale and remote storage.
|
|||
Depending on the storage, `Defaults.Keys` will be represented in different forms due to storage limitations of the remote storage. The remote storage imposes a limitation of 1024 keys. Therefore, we combine the recorded timestamp and data into a single key. Unlike remote storage, local storage does not have this limitation. Therefore, we can create a separate key (with `defaultsSyncKey` suffix) for the timestamp record.
|
||||
*/
|
||||
final class iCloudSynchronizer {
|
||||
init(remoteStorage: DefaultsKeyValueStore) {
|
||||
init(remoteStorage: any DefaultsKeyValueStore) {
|
||||
self.remoteStorage = remoteStorage
|
||||
registerNotifications()
|
||||
remoteStorage.synchronize()
|
||||
|
@ -231,7 +231,7 @@ final class iCloudSynchronizer {
|
|||
/**
|
||||
A remote key value storage.
|
||||
*/
|
||||
private let remoteStorage: DefaultsKeyValueStore
|
||||
private let remoteStorage: any DefaultsKeyValueStore
|
||||
|
||||
/**
|
||||
A FIFO queue used to serialize synchronization on keys.
|
||||
|
|
|
@ -126,7 +126,7 @@ extension Defaults {
|
|||
|
||||
super.init(name: name, suite: suite)
|
||||
|
||||
if (defaultValue as? _DefaultsOptionalProtocol)?._defaults_isNil == true {
|
||||
if (defaultValue as? (any _DefaultsOptionalProtocol))?._defaults_isNil == true {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ extension Defaults {
|
|||
}
|
||||
|
||||
private static var preventPropagationThreadDictionaryKey: String {
|
||||
"\(type(of: Observation.self))_threadUpdatingValuesFlag"
|
||||
"\(type(of: (any Observation).self))_threadUpdatingValuesFlag"
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -460,7 +460,7 @@ extension Defaults {
|
|||
_ key: Key<Value>,
|
||||
options: ObservationOptions = [.initial],
|
||||
handler: @escaping (KeyChange<Value>) -> Void
|
||||
) -> Observation {
|
||||
) -> some Observation {
|
||||
let observation = UserDefaultsKeyObservation(object: key.suite, key: key.name) { change in
|
||||
handler(
|
||||
KeyChange(change: change, defaultValue: key.defaultValue)
|
||||
|
@ -490,7 +490,7 @@ extension Defaults {
|
|||
keys: _AnyKey...,
|
||||
options: ObservationOptions = [.initial],
|
||||
handler: @escaping () -> Void
|
||||
) -> Observation {
|
||||
) -> some Observation {
|
||||
let pairs = keys.map {
|
||||
(suite: $0.suite, key: $0.name)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ extension UserDefaults {
|
|||
}
|
||||
|
||||
func _set<Value: Defaults.Serializable>(_ key: String, to value: Value) {
|
||||
if (value as? _DefaultsOptionalProtocol)?._defaults_isNil == true {
|
||||
if (value as? (any _DefaultsOptionalProtocol))?._defaults_isNil == true {
|
||||
removeObject(forKey: key)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue