mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Find all the usages of `--enable-experimental-feature` or `--enable-upcoming-feature` in the tests and replace some of the `REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which should correctly apply to depending on the asserts/noasserts mode of the toolchain for each feature. Remove some comments that talked about enabling asserts since they don't apply anymore (but I might had miss some). All this was done with an automated script, so some formatting weirdness might happen, but I hope I fixed most of those. There might be some tests that were `REQUIRES: asserts` that might run in `noasserts` toolchains now. This will normally be because their feature went from experimental to upcoming/base and the tests were not updated.
90 lines
2.5 KiB
Swift
90 lines
2.5 KiB
Swift
// RUN: %target-swift-frontend -dump-ast %s -target %target-swift-5.1-abi-triple -enable-experimental-feature ClosureIsolation | %FileCheck %s
|
|
|
|
// REQUIRES: concurrency
|
|
// REQUIRES: swift_feature_ClosureIsolation
|
|
|
|
func acceptClosure<T>(_: () -> T) { }
|
|
func acceptSendableClosure<T>(_: @Sendable () -> T) { }
|
|
|
|
func acceptAsyncClosure<T>(_: () async -> T) { }
|
|
func acceptEscapingAsyncClosure<T>(_: @escaping () async -> T) { }
|
|
|
|
actor MyActor {
|
|
func method() async -> String { "" }
|
|
func syncMethod() -> String { "" }
|
|
}
|
|
|
|
extension MyActor {
|
|
// CHECK-LABEL: testClosureIsolation
|
|
func testClosureIsolation() async {
|
|
// CHECK: acceptClosure
|
|
// CHECK: closure_expr
|
|
// CHECK: actor_isolated
|
|
acceptClosure { self.syncMethod() }
|
|
|
|
// CHECK: acceptSendableClosure
|
|
// CHECK: closure_expr
|
|
// CHECK-NOT: actor_isolated
|
|
acceptSendableClosure { print(self) }
|
|
|
|
// CHECK: acceptAsyncClosure
|
|
// CHECK: closure_expr
|
|
// CHECK-SAME: actor_isolated="closure_isolation.(file).MyActor extension.testClosureIsolation().self@
|
|
acceptAsyncClosure { await method() }
|
|
|
|
// CHECK: acceptAsyncClosure
|
|
// CHECK: closure_expr
|
|
// CHECK-NOT: actor_isolated
|
|
acceptAsyncClosure { () async in print() }
|
|
|
|
// CHECK: acceptEscapingAsyncClosure
|
|
// CHECK: closure_expr
|
|
// CHECK: actor_isolated
|
|
acceptEscapingAsyncClosure { self.syncMethod() }
|
|
|
|
// CHECK: acceptEscapingAsyncClosure
|
|
// CHECK: closure_expr
|
|
// CHECK: actor_isolated
|
|
acceptEscapingAsyncClosure { () async in print(self) }
|
|
|
|
// CHECK: acceptClosure
|
|
// CHECK: closure_expr
|
|
// CHECK: nonisolated
|
|
acceptClosure { nonisolated in print() }
|
|
}
|
|
}
|
|
|
|
actor SomeActor { }
|
|
|
|
@globalActor
|
|
struct SomeGlobalActor {
|
|
static let shared = SomeActor()
|
|
}
|
|
|
|
func someAsyncFunc() async { }
|
|
|
|
@SomeGlobalActor func getGlobal7() -> Int { 7 }
|
|
|
|
// CHECK-LABEL: someGlobalActorFunc
|
|
@SomeGlobalActor func someGlobalActorFunc() async {
|
|
// CHECK: acceptAsyncClosure
|
|
// CHECK: closure_expr
|
|
// CHECK-SAME: global_actor_isolated="SomeGlobalActor"
|
|
acceptAsyncClosure { await someAsyncFunc() }
|
|
|
|
// CHECK: acceptAsyncClosure
|
|
// CHECK: closure_expr
|
|
// CHECK-SAME: global_actor_isolated="SomeGlobalActor"
|
|
acceptAsyncClosure { () async in print("hello") }
|
|
|
|
// CHECK: acceptEscapingAsyncClosure
|
|
// CHECK: closure_expr
|
|
// CHECK: actor_isolated
|
|
acceptEscapingAsyncClosure { await someAsyncFunc() }
|
|
|
|
// CHECK: acceptEscapingAsyncClosure
|
|
// CHECK: closure_expr
|
|
// CHECK: actor_isolated
|
|
acceptEscapingAsyncClosure { () async in print("hello") }
|
|
}
|