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(
9191#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
9292@available ( StdlibDeploymentTarget 6 . 2 , * )
9393@_silgen_name ( " swift_getMainExecutor " )
94- internal func _getMainExecutor ( ) -> any SerialExecutor {
94+ internal func _getMainExecutorAsSerialExecutor ( ) -> ( any SerialExecutor ) ? {
9595 return MainActor . executor
9696}
9797#else
9898// For task-to-thread model, this is implemented in C++
9999@available ( StdlibDeploymentTarget 6 . 2 , * )
100100@_silgen_name ( " swift_getMainExecutor " )
101- internal func _getMainExecutor ( ) -> any SerialExecutor
101+ internal func _getMainExecutorAsSerialExecutor ( ) -> ( any SerialExecutor ) ?
102102#endif // SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
103103#endif // !$Embedded
104104
Original file line number Diff line number Diff line change @@ -47,7 +47,11 @@ internal func donateToGlobalExecutor(
4747@available ( SwiftStdlib 6 . 2 , * )
4848@_silgen_name ( " swift_task_getMainExecutorImpl " )
4949internal 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)
5155}
5256
5357@available ( SwiftStdlib 6 . 2 , * )
You can’t perform that action at this time.
0 commit comments