Skip to content

Commit 8a331b6

Browse files
committed
Fix concurrency warnings
1 parent 668a657 commit 8a331b6

8 files changed

+25
-25
lines changed

Sources/IntrospectionSelector.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#if !os(watchOS)
22
@_spi(Advanced)
3-
public struct IntrospectionSelector<Target: PlatformEntity> {
3+
public struct IntrospectionSelector<Target: PlatformEntity>: Sendable {
44
@_spi(Advanced)
55
public static var `default`: Self { .from(Target.self, selector: { $0 }) }
66

@@ -16,32 +16,32 @@ public struct IntrospectionSelector<Target: PlatformEntity> {
1616
)
1717
}
1818

19-
private var receiverSelector: (IntrospectionPlatformViewController) -> Target?
20-
private var ancestorSelector: (IntrospectionPlatformViewController) -> Target?
19+
private var receiverSelector: @MainActor @Sendable (IntrospectionPlatformViewController) -> Target?
20+
private var ancestorSelector: @MainActor @Sendable (IntrospectionPlatformViewController) -> Target?
2121

2222
private init(
23-
receiverSelector: @escaping (IntrospectionPlatformViewController) -> Target?,
24-
ancestorSelector: @escaping (IntrospectionPlatformViewController) -> Target?
23+
receiverSelector: @MainActor @Sendable @escaping (IntrospectionPlatformViewController) -> Target?,
24+
ancestorSelector: @MainActor @Sendable @escaping (IntrospectionPlatformViewController) -> Target?
2525
) {
2626
self.receiverSelector = receiverSelector
2727
self.ancestorSelector = ancestorSelector
2828
}
2929

3030
@_spi(Advanced)
31-
public func withReceiverSelector(_ selector: @escaping (PlatformViewController) -> Target?) -> Self {
31+
public func withReceiverSelector(_ selector: @MainActor @Sendable @escaping (PlatformViewController) -> Target?) -> Self {
3232
var copy = self
3333
copy.receiverSelector = selector
3434
return copy
3535
}
3636

3737
@_spi(Advanced)
38-
public func withAncestorSelector(_ selector: @escaping (PlatformViewController) -> Target?) -> Self {
38+
public func withAncestorSelector(_ selector: @MainActor @Sendable @escaping (PlatformViewController) -> Target?) -> Self {
3939
var copy = self
4040
copy.ancestorSelector = selector
4141
return copy
4242
}
4343

44-
func callAsFunction(_ controller: IntrospectionPlatformViewController, _ scope: IntrospectionScope) -> Target? {
44+
@MainActor func callAsFunction(_ controller: IntrospectionPlatformViewController, _ scope: IntrospectionScope) -> Target? {
4545
if
4646
scope.contains(.receiver),
4747
let target = receiverSelector(controller)

Sources/PlatformVersion.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import Foundation
33

44
@_spi(Internals)
5-
public enum PlatformVersionCondition {
5+
public enum PlatformVersionCondition: Sendable {
66
case past
77
case current
88
case future
99
}
1010

11-
public protocol PlatformVersion {
11+
public protocol PlatformVersion: Sendable {
1212
@_spi(Internals)
1313
var condition: PlatformVersionCondition? { get }
1414
}

Sources/PlatformViewVersion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public typealias macOSViewVersion<SwiftUIViewType: IntrospectableViewType, Platf
6161
public typealias visionOSViewVersion<SwiftUIViewType: IntrospectableViewType, PlatformSpecificEntity: PlatformEntity> =
6262
PlatformViewVersion<visionOSVersion, SwiftUIViewType, PlatformSpecificEntity>
6363

64-
public enum PlatformViewVersion<Version: PlatformVersion, SwiftUIViewType: IntrospectableViewType, PlatformSpecificEntity: PlatformEntity> {
64+
public enum PlatformViewVersion<Version: PlatformVersion, SwiftUIViewType: IntrospectableViewType, PlatformSpecificEntity: PlatformEntity>: Sendable {
6565
@_spi(Internals) case available(Version, IntrospectionSelector<PlatformSpecificEntity>?)
6666
@_spi(Internals) case unavailable
6767

Sources/ViewTypes/NavigationSplitView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ extension iOSViewVersion<NavigationSplitViewType, UISplitViewController> {
9090
public static let v18 = Self(for: .v18, selector: selector)
9191

9292
private static var selector: IntrospectionSelector<UISplitViewController> {
93-
.default.withAncestorSelector(\.splitViewController)
93+
.default.withAncestorSelector({ $0.splitViewController })
9494
}
9595
}
9696

@@ -107,7 +107,7 @@ extension tvOSViewVersion<NavigationSplitViewType, UINavigationController> {
107107
public static let v18 = Self(for: .v18, selector: selector)
108108

109109
private static var selector: IntrospectionSelector<UINavigationController> {
110-
.default.withAncestorSelector(\.navigationController)
110+
.default.withAncestorSelector { $0.navigationController }
111111
}
112112
}
113113

@@ -116,7 +116,7 @@ extension visionOSViewVersion<NavigationSplitViewType, UISplitViewController> {
116116
public static let v2 = Self(for: .v2, selector: selector)
117117

118118
private static var selector: IntrospectionSelector<UISplitViewController> {
119-
.default.withAncestorSelector(\.splitViewController)
119+
.default.withAncestorSelector { $0.splitViewController }
120120
}
121121
}
122122
#elseif canImport(AppKit)

Sources/ViewTypes/NavigationStack.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension iOSViewVersion<NavigationStackType, UINavigationController> {
7171
public static let v18 = Self(for: .v18, selector: selector)
7272

7373
private static var selector: IntrospectionSelector<UINavigationController> {
74-
.default.withAncestorSelector(\.navigationController)
74+
.default.withAncestorSelector { $0.navigationController }
7575
}
7676
}
7777

@@ -88,7 +88,7 @@ extension tvOSViewVersion<NavigationStackType, UINavigationController> {
8888
public static let v18 = Self(for: .v18, selector: selector)
8989

9090
private static var selector: IntrospectionSelector<UINavigationController> {
91-
.default.withAncestorSelector(\.navigationController)
91+
.default.withAncestorSelector { $0.navigationController }
9292
}
9393
}
9494

@@ -97,7 +97,7 @@ extension visionOSViewVersion<NavigationStackType, UINavigationController> {
9797
public static let v2 = Self(for: .v2, selector: selector)
9898

9999
private static var selector: IntrospectionSelector<UINavigationController> {
100-
.default.withAncestorSelector(\.navigationController)
100+
.default.withAncestorSelector { $0.navigationController }
101101
}
102102
}
103103
#endif

Sources/ViewTypes/NavigationViewWithColumnsStyle.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extension iOSViewVersion<NavigationViewWithColumnsStyleType, UISplitViewControll
8686
public static let v18 = Self(for: .v18, selector: selector)
8787

8888
private static var selector: IntrospectionSelector<UISplitViewController> {
89-
.default.withAncestorSelector(\.splitViewController)
89+
.default.withAncestorSelector { $0.splitViewController }
9090
}
9191
}
9292

@@ -99,7 +99,7 @@ extension tvOSViewVersion<NavigationViewWithColumnsStyleType, UINavigationContro
9999
public static let v18 = Self(for: .v18, selector: selector)
100100

101101
private static var selector: IntrospectionSelector<UINavigationController> {
102-
.default.withAncestorSelector(\.navigationController)
102+
.default.withAncestorSelector { $0.navigationController }
103103
}
104104
}
105105

@@ -108,7 +108,7 @@ extension visionOSViewVersion<NavigationViewWithColumnsStyleType, UISplitViewCon
108108
public static let v2 = Self(for: .v2, selector: selector)
109109

110110
private static var selector: IntrospectionSelector<UISplitViewController> {
111-
.default.withAncestorSelector(\.splitViewController)
111+
.default.withAncestorSelector { $0.splitViewController }
112112
}
113113
}
114114
#elseif canImport(AppKit)

Sources/ViewTypes/NavigationViewWithStackStyle.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ extension iOSViewVersion<NavigationViewWithStackStyleType, UINavigationControlle
7474
public static let v18 = Self(for: .v18, selector: selector)
7575

7676
private static var selector: IntrospectionSelector<UINavigationController> {
77-
.default.withAncestorSelector(\.navigationController)
77+
.default.withAncestorSelector { $0.navigationController }
7878
}
7979
}
8080

@@ -87,7 +87,7 @@ extension tvOSViewVersion<NavigationViewWithStackStyleType, UINavigationControll
8787
public static let v18 = Self(for: .v18, selector: selector)
8888

8989
private static var selector: IntrospectionSelector<UINavigationController> {
90-
.default.withAncestorSelector(\.navigationController)
90+
.default.withAncestorSelector { $0.navigationController }
9191
}
9292
}
9393

@@ -96,7 +96,7 @@ extension visionOSViewVersion<NavigationViewWithStackStyleType, UINavigationCont
9696
public static let v2 = Self(for: .v2, selector: selector)
9797

9898
private static var selector: IntrospectionSelector<UINavigationController> {
99-
.default.withAncestorSelector(\.navigationController)
99+
.default.withAncestorSelector { $0.navigationController }
100100
}
101101
}
102102
#endif

Sources/ViewTypes/TabView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension iOSViewVersion<TabViewType, UITabBarController> {
7171
public static let v18 = Self(for: .v18, selector: selector)
7272

7373
private static var selector: IntrospectionSelector<UITabBarController> {
74-
.default.withAncestorSelector(\.tabBarController)
74+
.default.withAncestorSelector { $0.tabBarController }
7575
}
7676
}
7777

@@ -84,7 +84,7 @@ extension tvOSViewVersion<TabViewType, UITabBarController> {
8484
public static let v18 = Self(for: .v18, selector: selector)
8585

8686
private static var selector: IntrospectionSelector<UITabBarController> {
87-
.default.withAncestorSelector(\.tabBarController)
87+
.default.withAncestorSelector { $0.tabBarController }
8888
}
8989
}
9090
#elseif canImport(AppKit)

0 commit comments

Comments
 (0)