Files
swift-mirror/test/Concurrency/unsafe_inherit_executor.swift
Michael Gottesman 99e3f7fb13 [region-isolation] Make RegionBasedIsolation an upcoming feature for swift 6.
To make the tests pass, I had to teach sil-opt how to setup upcoming features
since it did not know how to parse them.

rdar://124100266
2024-03-05 15:15:14 -08:00

42 lines
1.3 KiB
Swift

// RUN: %target-swift-frontend -emit-sil -o /dev/null -verify -disable-availability-checking %s
// RUN: %target-swift-frontend -emit-sil -o /dev/null -verify -disable-availability-checking %s -strict-concurrency=targeted
// RUN: %target-swift-frontend -emit-sil -o /dev/null -verify -disable-availability-checking %s -strict-concurrency=complete
// RUN: %target-swift-frontend -emit-sil -o /dev/null -verify -disable-availability-checking %s -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
// REQUIRES: asserts
// expected-error @+1 {{non-async functions cannot inherit an executor}}
@_unsafeInheritExecutor
func testNonAsync() {}
@_unsafeInheritExecutor
func testAsync() async {}
struct A {
// expected-error @+1 {{@_unsafeInheritExecutor may only be used on 'func' declarations}}
@_unsafeInheritExecutor
init() async {}
// expected-error @+1 {{non-async functions cannot inherit an executor}}
@_unsafeInheritExecutor
func testNonAsync() {}
@_unsafeInheritExecutor
func testAsync() async {}
}
class NonSendableObject {
var property = 0
}
@_unsafeInheritExecutor
func useNonSendable(object: NonSendableObject) async {}
actor MyActor {
var object = NonSendableObject()
func foo() async {
await useNonSendable(object: self.object)
}
}