Skip to content

Commit 9424b18

Browse files
committed
Fix 6.2 compilation failure
1 parent 3eb62da commit 9424b18

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
#if compiler(<6.2)
2-
import Dispatch
1+
import Dispatch
32

4-
func mainActorNow<R: Sendable>(execute block: @MainActor @Sendable () -> R) -> R {
5-
if DispatchQueue.getSpecific(key: key) == value {
6-
return MainActor._assumeIsolated {
3+
func mainActorNow<R: Sendable>(execute block: @MainActor @Sendable () -> R) -> R {
4+
if DispatchQueue.getSpecific(key: key) == value {
5+
return MainActor._assumeIsolated {
6+
block()
7+
}
8+
} else {
9+
return DispatchQueue.main.sync {
10+
MainActor._assumeIsolated {
711
block()
812
}
9-
} else {
10-
return DispatchQueue.main.sync {
11-
MainActor._assumeIsolated {
12-
block()
13-
}
14-
}
1513
}
1614
}
15+
}
1716

18-
private let key: DispatchSpecificKey<UInt8> = {
19-
let key = DispatchSpecificKey<UInt8>()
20-
DispatchQueue.main.setSpecific(key: key, value: value)
21-
return key
22-
}()
23-
private let value: UInt8 = 0
24-
#endif
17+
private let key: DispatchSpecificKey<UInt8> = {
18+
let key = DispatchSpecificKey<UInt8>()
19+
DispatchQueue.main.setSpecific(key: key, value: value)
20+
return key
21+
}()
22+
private let value: UInt8 = 0

0 commit comments

Comments
 (0)