Skip to content

Commit d197f38

Browse files
committed
[Concurrency] Make currentExecutor return a non-optional.
If we don't have any other executor to return, return the default executor. rdar://141348916
1 parent 00e7ef2 commit d197f38

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/public/Concurrency/Executor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,15 +600,15 @@ extension Task where Success == Never, Failure == Never {
600600
/// If none of these exist, this property will be `nil`.
601601
@available(SwiftStdlib 6.2, *)
602602
@_unavailableInEmbedded
603-
public static var currentExecutor: (any Executor)? {
603+
public static var currentExecutor: any Executor {
604604
if let activeExecutor = unsafe _getActiveExecutor().asSerialExecutor() {
605605
return activeExecutor
606606
} else if let taskExecutor = unsafe _getPreferredTaskExecutor().asTaskExecutor() {
607607
return taskExecutor
608608
} else if let taskExecutor = unsafe _getCurrentTaskExecutor().asTaskExecutor() {
609609
return taskExecutor
610610
}
611-
return nil
611+
return defaultExecutor
612612
}
613613

614614
/// Get the preferred executor for the current `Task`, if any.

0 commit comments

Comments
 (0)