Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sending arguments cannot be sent into actor-isolated implementation #78588

Open
azarovalex opened this issue Jan 12, 2025 · 1 comment
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@azarovalex
Copy link

azarovalex commented Jan 12, 2025

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

@azarovalex azarovalex added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jan 12, 2025
@azarovalex
Copy link
Author

Seems like #78601 fixes both this issue and #76710, thanks @stzn for looking into that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant