Просмотр исходного кода

Fix warnings reported by new compiler

onevcat 1 год назад
Родитель
Сommit
94f6ec130c

+ 1 - 1
Sources/Cache/ImageCache.swift

@@ -835,7 +835,7 @@ open class ImageCache: @unchecked Sendable {
         cleanExpiredDiskCache {
             Task {
                 guard let bgTask = await taskActor.value, bgTask != .invalid else { return }
-                await sharedApplication.endBackgroundTask(bgTask)
+                sharedApplication.endBackgroundTask(bgTask)
                 await taskActor.setValue(.invalid)
             }
         }

+ 1 - 0
Sources/General/KFOptionsSetter.swift

@@ -33,6 +33,7 @@ import UIKit
 #endif
 
 /// A protocol that Kingfisher can use to perform chained setting in builder pattern.
+@MainActor
 public protocol KFOptionSetter {
     var options: KingfisherParsedOptionsInfo { get nonmutating set }
 

+ 1 - 1
Sources/General/KingfisherManager.swift

@@ -922,7 +922,7 @@ class CacheCallbackCoordinator: @unchecked Sendable {
     private let stateQueue: DispatchQueue
     private var threadSafeState: State = .idle
 
-    private (set) var state: State {
+    private(set) var state: State {
         set { stateQueue.sync { threadSafeState = newValue } }
         get { stateQueue.sync { threadSafeState } }
     }

+ 3 - 3
Sources/Image/Image.swift

@@ -45,9 +45,9 @@ import ImageIO
 import UniformTypeIdentifiers
 #endif
 
-private let animatedImageDataKey = malloc(1)!
-private let imageFrameCountKey = malloc(1)!
-private let imageSourceKey = malloc(1)!
+nonisolated(unsafe) private let animatedImageDataKey = malloc(1)!
+nonisolated(unsafe) private let imageFrameCountKey = malloc(1)!
+nonisolated(unsafe) private let imageSourceKey = malloc(1)!
 
 // MARK: - Image Properties
 extension KingfisherWrapper where Base: KFCrossPlatformImage {

+ 1 - 1
Sources/Networking/SessionDelegate.swift

@@ -30,7 +30,7 @@ import Foundation
 ///
 /// It also behaves like a task manager for downloading.
 @objc(KFSessionDelegate) // Fix for ObjC header name conflicting. https://github.com/onevcat/Kingfisher/issues/1530
-open class SessionDelegate: NSObject {
+open class SessionDelegate: NSObject, @unchecked Sendable {
 
     typealias SessionChallengeFunc = (
         URLSession,

+ 2 - 0
Sources/SwiftUI/KFImageProtocol.swift

@@ -35,6 +35,7 @@ import Combine
 /// ``KFAnimatedImage`` conform this type and should be used in your app to represent an image view with network and
 /// cache support in SwiftUI.
 @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
+@MainActor
 public protocol KFImageProtocol: View, KFOptionSetter {
     associatedtype HoldingView: KFImageHoldingView
     var context: KFImage.Context<HoldingView> { get set }
@@ -103,6 +104,7 @@ extension KFImageProtocol {
 }
 
 @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
+@MainActor
 public protocol KFImageHoldingView: View {
     associatedtype RenderingView
     static func created(from image: KFCrossPlatformImage?, context: KFImage.Context<Self>) -> Self

+ 1 - 1
Sources/Utility/CallbackQueue.swift

@@ -85,7 +85,7 @@ enum CallbackQueueMain {
 
 extension MainActor {
     @_unavailableFromAsync
-    static func runUnsafely<T>(_ body: @MainActor () throws -> T) rethrows -> T {
+    static func runUnsafely<T: Sendable>(_ body: @MainActor () throws -> T) rethrows -> T {
 #if swift(>=5.10)
         return try MainActor.assumeIsolated(body)
 #else

+ 1 - 1
Sources/Utility/DisplayLink.swift

@@ -52,7 +52,7 @@ extension UIView {
     }
 }
 
-extension CADisplayLink: DisplayLinkCompatible, @unchecked Sendable {}
+extension CADisplayLink: DisplayLinkCompatible, @retroactive @unchecked Sendable {}
 
 #else
 extension NSView {