Open
Description
Description
When an actor isolated type implements a protocol that has a function with sending
arguments, compiler still requires the argument to be Sendable
.
My understanding is that the caller should be able to safely pass even non-sendable arguments, since the protocol itself requires "sending" the arguments to the implementation, which should prevent the caller from further accessing the shared mutable state.
I was able to find a similar issue that concerns return values: #76710, also still relevant.
Reproduction
class Test {}
protocol Foo {
func bar(a: sending Test) async
}
@MainActor
public class FooImpl: Foo {
func bar(a: sending Test) async {}
// `- error: non-sendable parameter type 'Test' cannot be sent from caller of protocol requirement 'bar(a:)' into main actor-isolated implementation
}
Expected behavior
Code compiles.
Environment
Latest main
as of today:
Swift version 6.2-dev (LLVM e67c0c37f2274ef, Swift aea6b38)
Target: arm64-apple-macosx15.0
Additional information
No response