Skip to content

Commit 2bd43fd

Browse files
committed
[sending] Add some code coverage for globals.
(cherry picked from commit bfb5096)
1 parent 74841a5 commit 2bd43fd

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

test/Concurrency/sending_conditional_suppression.swift

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ public struct TestInStruct {
192192

193193
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
194194
// CHECK-NEXT: @usableFromInline
195-
// CHECK-NEXT: internal init(_ x: Int, transformWithResult: @escaping () async throws -> sending test.NonSendableKlass) { fatalError() }
195+
// CHECK-NEXT: internal init(_ x: Swift.Int, transformWithResult: @escaping () async throws -> sending test.NonSendableKlass)
196196
// CHECK-NEXT: #else
197197
// CHECK-NEXT: @usableFromInline
198-
// CHECK-NEXT: internal init(_ x: Int, transformWithResult: @escaping () async throws -> test.NonSendableKlass) { fatalError() }
198+
// CHECK-NEXT: internal init(_ x: Swift.Int, transformWithResult: @escaping () async throws -> test.NonSendableKlass)
199199
// CHECK-NEXT: #endif
200200
@usableFromInline
201201
internal init(_ x: Int, transformWithResult: @escaping () async throws -> sending NonSendableKlass) { fatalError() }
@@ -204,19 +204,38 @@ public struct TestInStruct {
204204
// Make sure that we emit compiler(>= 5.3) when emitting the suppressing check
205205
// to make sure we do not fail if we fail to parse sending in the if block.
206206

207-
// CHECK: #if compiler(>=5.3) && $OptionalIsolatedParameters && $ExpressionMacroDefaultArguments
208-
// CHECK-NEXT: #if compiler(>=5.3) && $SendingArgsAndResults
209-
// CHECK-NEXT: @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
210-
// CHECK-NEXT: @backDeployed(before: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999)
211-
// CHECK-NEXT: @inlinable public func withCheckedContinuation<T>(isolation:
212-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
213-
@backDeployed(before: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999)
207+
// CHECK-LABEL: #if compiler(>=5.3) && $OptionalIsolatedParameters && $ExpressionMacroDefaultArguments // Suppression Count: 24
208+
// CHECK-NEXT: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 25
209+
// CHECK-NEXT: @inlinable public func withCheckedContinuation<T>(isolation: isolated (any _Concurrency.Actor)? = #isolation, function: Swift.String = #function, _ body: (_Concurrency.CheckedContinuation<T, Swift.Never>) -> Swift.Void) async -> sending T {
210+
// CHECK-NEXT: fatalError()
211+
// CHECK-NEXT: }
212+
// CHECK-NEXT: #else
213+
// CHECK-NEXT: @inlinable public func withCheckedContinuation<T>(isolation: isolated (any _Concurrency.Actor)? = #isolation, function: Swift.String = #function, _ body: (_Concurrency.CheckedContinuation<T, Swift.Never>) -> Swift.Void) async -> T {
214+
// CHECK-NEXT: fatalError()
215+
// CHECK-NEXT: }
216+
// CHECK-NEXT: #endif
217+
// CHECK-NEXT: #endif
214218
@inlinable public func withCheckedContinuation<T>(
215219
isolation: isolated (any _Concurrency.Actor)? = #isolation,
216220
function: String = #function,
217221
_ body: (_Concurrency.CheckedContinuation<T, Swift.Never>) -> Swift.Void
218222
) async -> sending T {
219-
return await withUnsafeContinuation {
220-
body(CheckedContinuation(continuation: $0, function: function))
221-
}
223+
fatalError()
222224
}
225+
226+
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 26
227+
// CHECK-NEXT: public var publicGlobal: (sending test.NonSendableKlass) -> ()
228+
// CHECK-NEXT: #else
229+
// CHECK-NEXT: public var publicGlobal: (test.NonSendableKlass) -> ()
230+
// CHECK-NEXT: #endif
231+
public var publicGlobal: (sending NonSendableKlass) -> () = { x in fatalError() }
232+
233+
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults // Suppression Count: 27
234+
// CHECK-NEXT: @usableFromInline
235+
// CHECK-NEXT: internal var usableFromInlineGlobal: (sending test.NonSendableKlass) -> ()
236+
// CHECK-NEXT: #else
237+
// CHECK-NEXT: @usableFromInline
238+
// CHECK-NEXT: internal var usableFromInlineGlobal: (test.NonSendableKlass) -> ()
239+
// CHECK-NEXT: #endif
240+
@usableFromInline
241+
internal var usableFromInlineGlobal: (sending NonSendableKlass) -> () = { x in fatalError() }

0 commit comments

Comments
 (0)