From 9a7c0b9869c22f1041733ae6cb2a29df2c3bf7fa Mon Sep 17 00:00:00 2001 From: nate-chandler <46721658+nate-chandler@users.noreply.github.com> Date: Wed, 14 Sep 2022 17:29:49 -0700 Subject: [PATCH] Revert "[Freestanding] Disable checked continuations." --- .../Concurrency/CheckedContinuation.swift | 64 ------------------- test/stdlib/freestanding_diags_stdlib.swift | 7 -- 2 files changed, 71 deletions(-) diff --git a/stdlib/public/Concurrency/CheckedContinuation.swift b/stdlib/public/Concurrency/CheckedContinuation.swift index d29dcbc3b1906..03b1426bdd8ea 100644 --- a/stdlib/public/Concurrency/CheckedContinuation.swift +++ b/stdlib/public/Concurrency/CheckedContinuation.swift @@ -16,7 +16,6 @@ import Swift @_silgen_name("swift_continuation_logFailedCheck") internal func logFailedCheck(_ message: UnsafeRawPointer) -#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY /// Implementation class that holds the `UnsafeContinuation` instance for /// a `CheckedContinuation`. @available(SwiftStdlib 5.1, *) @@ -83,9 +82,7 @@ internal final class CheckedContinuationCanary: @unchecked Sendable { } } } -#endif -#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY /// A mechanism to interface /// between synchronous and asynchronous code, /// logging correctness violations. @@ -299,65 +296,4 @@ public func withCheckedThrowingContinuation( body(CheckedContinuation(continuation: $0, function: function)) } } -#else -@available(SwiftStdlib 5.1, *) -@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") -public struct CheckedContinuation: Sendable { - @available(SwiftStdlib 5.1, *) - @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") - public init(continuation: UnsafeContinuation, function: String = #function) { - fatalError("Unavailable in task-to-thread concurrency model") - } - - @available(SwiftStdlib 5.1, *) - @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") - public func resume(returning value: __owned T) { - fatalError("Unavailable in task-to-thread concurrency model") - } - - @available(SwiftStdlib 5.1, *) - @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") - public func resume(throwing error: __owned E) { - fatalError("Unavailable in task-to-thread concurrency model") - } -} -@available(SwiftStdlib 5.1, *) -@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") -extension CheckedContinuation { - @available(SwiftStdlib 5.1, *) - @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") - public func resume(with result: Result) where E == Error { - fatalError("Unavailable in task-to-thread concurrency model") - } - - @available(SwiftStdlib 5.1, *) - @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") - public func resume(with result: Result) { - fatalError("Unavailable in task-to-thread concurrency model") - } - @available(SwiftStdlib 5.1, *) - @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") - public func resume() where T == Void { - fatalError("Unavailable in task-to-thread concurrency model") - } -} - -@available(SwiftStdlib 5.1, *) -@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") -public func withCheckedContinuation( - function: String = #function, - _ body: (CheckedContinuation) -> Void -) async -> T { - fatalError("Unavailable in task-to-thread concurrency model") -} - -@available(SwiftStdlib 5.1, *) -@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") -public func withCheckedThrowingContinuation( - function: String = #function, - _ body: (CheckedContinuation) -> Void -) async throws -> T { - fatalError("Unavailable in task-to-thread concurrency model") -} -#endif diff --git a/test/stdlib/freestanding_diags_stdlib.swift b/test/stdlib/freestanding_diags_stdlib.swift index 64a29fe900859..040b888e5e53a 100644 --- a/test/stdlib/freestanding_diags_stdlib.swift +++ b/test/stdlib/freestanding_diags_stdlib.swift @@ -24,13 +24,6 @@ func foo() async { asyncDetached { () async -> () in } // expected-error{{Unavailable in task-to-thread concurrency model}} asyncDetached { () async throws -> () in } // expected-error{{Unavailable in task-to-thread concurrency model}} _ = MainActor.self // expected-error{{Unavailable in task-to-thread concurrency model}} - let _: Int = await withCheckedContinuation { _ in } // expected-error{{Unavailable in task-to-thread concurrency model}} - do { - let _: Int = try await withCheckedThrowingContinuation { _ in } // expected-error{{Unavailable in task-to-thread concurrency model}} - } catch let error { - _ = error - } - _ = CheckedContinuation.self // expected-error{{Unavailable in task-to-thread concurrency model}} } func foo2(