Skip to content

Commit 5c6d5bf

Browse files
Use explicit any (#180)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent d8a954e commit 5c6d5bf

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Sources/Defaults/Defaults+iCloud.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Manages `Defaults.Keys` between the locale and remote storage.
209209
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.
210210
*/
211211
final class iCloudSynchronizer {
212-
init(remoteStorage: DefaultsKeyValueStore) {
212+
init(remoteStorage: any DefaultsKeyValueStore) {
213213
self.remoteStorage = remoteStorage
214214
registerNotifications()
215215
remoteStorage.synchronize()
@@ -231,7 +231,7 @@ final class iCloudSynchronizer {
231231
/**
232232
A remote key value storage.
233233
*/
234-
private let remoteStorage: DefaultsKeyValueStore
234+
private let remoteStorage: any DefaultsKeyValueStore
235235

236236
/**
237237
A FIFO queue used to serialize synchronization on keys.

Sources/Defaults/Defaults.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ extension Defaults {
126126

127127
super.init(name: name, suite: suite)
128128

129-
if (defaultValue as? _DefaultsOptionalProtocol)?._defaults_isNil == true {
129+
if (defaultValue as? (any _DefaultsOptionalProtocol))?._defaults_isNil == true {
130130
return
131131
}
132132

Sources/Defaults/Observation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extension Defaults {
8585
}
8686

8787
private static var preventPropagationThreadDictionaryKey: String {
88-
"\(type(of: Observation.self))_threadUpdatingValuesFlag"
88+
"\(type(of: (any Observation).self))_threadUpdatingValuesFlag"
8989
}
9090

9191
/**
@@ -460,7 +460,7 @@ extension Defaults {
460460
_ key: Key<Value>,
461461
options: ObservationOptions = [.initial],
462462
handler: @escaping (KeyChange<Value>) -> Void
463-
) -> Observation {
463+
) -> some Observation {
464464
let observation = UserDefaultsKeyObservation(object: key.suite, key: key.name) { change in
465465
handler(
466466
KeyChange(change: change, defaultValue: key.defaultValue)
@@ -490,7 +490,7 @@ extension Defaults {
490490
keys: _AnyKey...,
491491
options: ObservationOptions = [.initial],
492492
handler: @escaping () -> Void
493-
) -> Observation {
493+
) -> some Observation {
494494
let pairs = keys.map {
495495
(suite: $0.suite, key: $0.name)
496496
}

Sources/Defaults/UserDefaults.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extension UserDefaults {
1010
}
1111

1212
func _set<Value: Defaults.Serializable>(_ key: String, to value: Value) {
13-
if (value as? _DefaultsOptionalProtocol)?._defaults_isNil == true {
13+
if (value as? (any _DefaultsOptionalProtocol))?._defaults_isNil == true {
1414
removeObject(forKey: key)
1515
return
1616
}

0 commit comments

Comments
 (0)