Open
Description
Description
AnyObject
is a protocol that is implicitly added to all class types, including non-Sendable classes. Therefore, AnyObject
itself should not be considered Sendable.
However, when used as a function argument, AnyObject
behaves as though it were Sendable.
Reproduction
func requireSendable(_: some Sendable) {}
func f(v: AnyObject) {
requireSendable(v) // OK
}
Expected behavior
Should be compile error. like Type 'AnyObject' does not conform to the 'Sendable' protocol
Environment
Swift version 6.0.1 (swift-6.0.1-RELEASE)
Target: x86_64-unknown-linux-gnu
Additional information
In the return value position, it behaves correctly:
func g(v: AnyObject) -> some Sendable {
return v // error: type 'AnyObject' does not conform to the 'Sendable' protocol
}