File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -91,14 +91,14 @@ internal func _jobGetExecutorPrivateData(
91
91
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
92
92
@available ( StdlibDeploymentTarget 6 . 2 , * )
93
93
@_silgen_name ( " swift_getMainExecutor " )
94
- internal func _getMainExecutor ( ) -> any SerialExecutor {
94
+ internal func _getMainExecutorAsSerialExecutor ( ) -> ( any SerialExecutor ) ? {
95
95
return MainActor . executor
96
96
}
97
97
#else
98
98
// For task-to-thread model, this is implemented in C++
99
99
@available ( StdlibDeploymentTarget 6 . 2 , * )
100
100
@_silgen_name ( " swift_getMainExecutor " )
101
- internal func _getMainExecutor ( ) -> any SerialExecutor
101
+ internal func _getMainExecutorAsSerialExecutor ( ) -> ( any SerialExecutor ) ?
102
102
#endif // SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
103
103
#endif // !$Embedded
104
104
Original file line number Diff line number Diff line change @@ -47,7 +47,11 @@ internal func donateToGlobalExecutor(
47
47
@available ( SwiftStdlib 6 . 2 , * )
48
48
@_silgen_name ( " swift_task_getMainExecutorImpl " )
49
49
internal func getMainExecutor( ) -> UnownedSerialExecutor {
50
- return unsafe _getMainExecutor( ) . asUnownedSerialExecutor ( )
50
+ let executor = _getMainExecutorAsSerialExecutor ( )
51
+ if let executor {
52
+ return unsafe executor. asUnownedSerialExecutor ( )
53
+ }
54
+ return unsafe unsafeBitCast( executor, to: UnownedSerialExecutor . self)
51
55
}
52
56
53
57
@available ( SwiftStdlib 6 . 2 , * )
You can’t perform that action at this time.
0 commit comments