Files
swift-mirror/test/Concurrency/unsafe_inherit_executor.swift
Doug Gregor 4bbca6af25 Calling @_unsafeInheritExecutor functions doesn't exit the current actor.
Fixes a spurious warning reported by rdar://95777456.
2022-07-03 23:11:29 -07:00

37 lines
843 B
Swift

// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking %s
// 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)
}
}