@@ -19,16 +19,15 @@ internal func logFailedCheck(_ message: UnsafeRawPointer)
1919/// Implementation class that holds the `UnsafeContinuation` instance for
2020/// a `CheckedContinuation`.
2121@available( SwiftStdlib 5 . 1 , * )
22- @_unavailableInEmbedded
2322internal final class CheckedContinuationCanary : @unchecked Sendable {
2423 // The instance state is stored in tail-allocated raw memory, so that
2524 // we can atomically check the continuation state.
2625
2726 private init ( ) { fatalError ( " must use create " ) }
2827
2928 private static func _create( continuation: UnsafeRawPointer , function: String )
30- -> Self {
31- let instance = Builtin . allocWithTailElems_1 ( self ,
29+ -> CheckedContinuationCanary {
30+ let instance = Builtin . allocWithTailElems_1 ( CheckedContinuationCanary . self,
3231 1 . _builtinWordValue,
3332 ( UnsafeRawPointer? , String) . self)
3433
@@ -52,7 +51,7 @@ internal final class CheckedContinuationCanary: @unchecked Sendable {
5251 }
5352
5453 internal static func create< T, E> ( continuation: UnsafeContinuation < T , E > ,
55- function: String ) -> Self {
54+ function: String ) -> CheckedContinuationCanary {
5655 return _create (
5756 continuation: unsafeBitCast ( continuation, to: UnsafeRawPointer . self) ,
5857 function: function)
@@ -79,7 +78,11 @@ internal final class CheckedContinuationCanary: @unchecked Sendable {
7978 // Log if the continuation was never consumed before the instance was
8079 // destructed.
8180 if _continuationPtr. pointee != nil {
81+ #if !$Embedded
8282 logFailedCheck ( " SWIFT TASK CONTINUATION MISUSE: \( function) leaked its continuation without resuming it. This may cause tasks waiting on it to remain suspended forever. \n " )
83+ #else
84+ fatalError ( " SWIFT TASK CONTINUATION MISUSE " )
85+ #endif
8386 }
8487 }
8588}
@@ -120,7 +123,6 @@ internal final class CheckedContinuationCanary: @unchecked Sendable {
120123/// you can replace one with the other in most circumstances,
121124/// without making other changes.
122125@available ( SwiftStdlib 5 . 1 , * )
123- @_unavailableInEmbedded
124126public struct CheckedContinuation < T, E: Error > : Sendable {
125127 private let canary : CheckedContinuationCanary
126128
@@ -163,7 +165,11 @@ public struct CheckedContinuation<T, E: Error>: Sendable {
163165 if let c: UnsafeContinuation < T , E > = canary. takeContinuation ( ) {
164166 c. resume ( returning: value)
165167 } else {
168+ #if !$Embedded
166169 fatalError ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, returning \( value) ! \n " )
170+ #else
171+ fatalError ( " SWIFT TASK CONTINUATION MISUSE " )
172+ #endif
167173 }
168174 }
169175
@@ -183,13 +189,16 @@ public struct CheckedContinuation<T, E: Error>: Sendable {
183189 if let c: UnsafeContinuation < T , E > = canary. takeContinuation ( ) {
184190 c. resume ( throwing: error)
185191 } else {
192+ #if !$Embedded
186193 fatalError ( " SWIFT TASK CONTINUATION MISUSE: \( canary. function) tried to resume its continuation more than once, throwing \( error) ! \n " )
194+ #else
195+ fatalError ( " SWIFT TASK CONTINUATION MISUSE " )
196+ #endif
187197 }
188198 }
189199}
190200
191201@available ( SwiftStdlib 5 . 1 , * )
192- @_unavailableInEmbedded
193202extension CheckedContinuation {
194203 /// Resume the task awaiting the continuation by having it either
195204 /// return normally or throw an error based on the state of the given
@@ -282,7 +291,6 @@ extension CheckedContinuation {
282291/// - SeeAlso: `withUnsafeContinuation(function:_:)`
283292/// - SeeAlso: `withUnsafeThrowingContinuation(function:_:)`
284293@inlinable
285- @_unavailableInEmbedded
286294@available ( SwiftStdlib 5 . 1 , * )
287295#if !$Embedded
288296@backDeployed ( before: SwiftStdlib 6.0 )
@@ -307,7 +315,6 @@ public func withCheckedContinuation<T>(
307315// introduction of #isolation.
308316@available ( SwiftStdlib 5 . 1 , * )
309317@_unsafeInheritExecutor // ABI compatibility with Swift 5.1
310- @_unavailableInEmbedded
311318@_silgen_name ( " $ss23withCheckedContinuation8function_xSS_yScCyxs5NeverOGXEtYalF " )
312319public func _unsafeInheritExecutor_withCheckedContinuation< T> (
313320 function: String = #function,
@@ -348,7 +355,6 @@ public func _unsafeInheritExecutor_withCheckedContinuation<T>(
348355/// - SeeAlso: `withUnsafeContinuation(function:_:)`
349356/// - SeeAlso: `withUnsafeThrowingContinuation(function:_:)`
350357@inlinable
351- @_unavailableInEmbedded
352358@available ( SwiftStdlib 5 . 1 , * )
353359#if !$Embedded
354360@backDeployed ( before: SwiftStdlib 6.0 )
@@ -373,7 +379,6 @@ public func withCheckedThrowingContinuation<T>(
373379// introduction of #isolation.
374380@available ( SwiftStdlib 5 . 1 , * )
375381@_unsafeInheritExecutor // ABI compatibility with Swift 5.1
376- @_unavailableInEmbedded
377382@_silgen_name ( " $ss31withCheckedThrowingContinuation8function_xSS_yScCyxs5Error_pGXEtYaKlF " )
378383public func _unsafeInheritExecutor_withCheckedThrowingContinuation< T> (
379384 function: String = #function,
0 commit comments