Skip to content

Fix existential-any for Swift6 #328

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Source/Shared/Library/ImageWrapper.swift
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ public struct ImageWrapper: Codable {
self.image = image
}

public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let data = try container.decode(Data.self, forKey: CodingKeys.image)
guard let image = Image(data: data) else {
@@ -25,7 +25,7 @@ public struct ImageWrapper: Codable {
self.image = image
}

public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
guard let data = image.cache_toData() else {
throw StorageError.encodingFailed
4 changes: 2 additions & 2 deletions Source/Shared/Library/JSONArrayWrapper.swift
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ public struct JSONArrayWrapper: Codable {
self.jsonArray = jsonArray
}

public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let data = try container.decode(Data.self, forKey: CodingKeys.jsonArray)
let object = try JSONSerialization.jsonObject(
@@ -28,7 +28,7 @@ public struct JSONArrayWrapper: Codable {
self.jsonArray = jsonArray
}

public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
let data = try JSONSerialization.data(
withJSONObject: jsonArray,
4 changes: 2 additions & 2 deletions Source/Shared/Library/JSONDictionaryWrapper.swift
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ public struct JSONDictionaryWrapper: Codable {
self.jsonDictionary = jsonDictionary
}

public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let data = try container.decode(Data.self, forKey: CodingKeys.jsonDictionary)
let object = try JSONSerialization.jsonObject(
@@ -28,7 +28,7 @@ public struct JSONDictionaryWrapper: Codable {
self.jsonDictionary = jsonDictionary
}

public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
let data = try JSONSerialization.data(
withJSONObject: jsonDictionary,
2 changes: 1 addition & 1 deletion Source/Shared/Library/Optional+Extension.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public extension Optional {
func unwrapOrThrow(error: Error) throws -> Wrapped {
func unwrapOrThrow(error: any Error) throws -> Wrapped {
if let value = self {
return value
} else {
16 changes: 8 additions & 8 deletions Source/Shared/Storage/AsyncStorage.swift
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ public class AsyncStorage<Key: Hashable, Value> {
}

extension AsyncStorage {
public func entry(forKey key: Key, completion: @escaping (Result<Entry<Value>, Error>) -> Void) {
public func entry(forKey key: Key, completion: @escaping (Result<Entry<Value>, any Error>) -> Void) {
serialQueue.async { [weak self] in
guard let `self` = self else {
completion(.failure(StorageError.deallocated))
@@ -30,7 +30,7 @@ extension AsyncStorage {
}
}

public func removeObject(forKey key: Key, completion: @escaping (Result<(), Error>) -> Void) {
public func removeObject(forKey key: Key, completion: @escaping (Result<(), any Error>) -> Void) {
serialQueue.async { [weak self] in
guard let `self` = self else {
completion(.failure(StorageError.deallocated))
@@ -50,7 +50,7 @@ extension AsyncStorage {
_ object: Value,
forKey key: Key,
expiry: Expiry? = nil,
completion: @escaping (Result<(), Error>) -> Void) {
completion: @escaping (Result<(), any Error>) -> Void) {
serialQueue.async { [weak self] in
guard let `self` = self else {
completion(.failure(StorageError.deallocated))
@@ -66,7 +66,7 @@ extension AsyncStorage {
}
}

public func removeAll(completion: @escaping (Result<(), Error>) -> Void) {
public func removeAll(completion: @escaping (Result<(), any Error>) -> Void) {
serialQueue.async { [weak self] in
guard let `self` = self else {
completion(.failure(StorageError.deallocated))
@@ -82,7 +82,7 @@ extension AsyncStorage {
}
}

public func removeExpiredObjects(completion: @escaping (Result<(), Error>) -> Void) {
public func removeExpiredObjects(completion: @escaping (Result<(), any Error>) -> Void) {
serialQueue.async { [weak self] in
guard let `self` = self else {
completion(.failure(StorageError.deallocated))
@@ -98,7 +98,7 @@ extension AsyncStorage {
}
}

public func object(forKey key: Key, completion: @escaping (Result<Value, Error>) -> Void) {
public func object(forKey key: Key, completion: @escaping (Result<Value, any Error>) -> Void) {
entry(forKey: key, completion: { (result: Result<Entry<Value>, Error>) in
completion(result.map({ entry in
return entry.object
@@ -109,7 +109,7 @@ extension AsyncStorage {
@available(*, deprecated, renamed: "objectExists(forKey:completion:)")
public func existsObject(
forKey key: Key,
completion: @escaping (Result<Bool, Error>) -> Void) {
completion: @escaping (Result<Bool, any Error>) -> Void) {
object(forKey: key, completion: { (result: Result<Value, Error>) in
completion(result.map({ _ in
return true
@@ -119,7 +119,7 @@ extension AsyncStorage {

public func objectExists(
forKey key: Key,
completion: @escaping (Result<Bool, Error>) -> Void) {
completion: @escaping (Result<Bool, any Error>) -> Void) {
object(forKey: key, completion: { (result: Result<Value, Error>) in
completion(result.map({ _ in
return true