-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Sendable checking for an an isolated witnesses to a nonisolated requirement #40560
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
Sendable checking for an an isolated witnesses to a nonisolated requirement #40560
Conversation
Fixes rdar://80424675.
…rement When a non-isolated requirement is witnessed by an actor-isolated witness, we are crossing into the actor. Ensure that we perform Sendable checking across the actor boundary here. Fixes the rest of rdar://80424675.
@swift-ci please smoke test |
// actor's domain. | ||
@available(SwiftStdlib 5.1, *) | ||
actor A3: AsyncProtocolWithNotSendable { | ||
func f() async -> NotSendable { NotSendable() } // expected-warning{{cannot call function returning non-sendable type 'NotSendable' across actors}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error message is super confusing here...? There is no call here 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we aren't customizing these diagnostics well as a general thing.
|
||
@MainActor | ||
class Object: Interface { | ||
var baz: Int = 42 // expected-warning{{property 'baz' isolated to global actor 'MainActor' can not satisfy corresponding requirement from protocol 'Interface'}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the fix here, explicitly annotating it with @mainactor? If so, can we get a fixit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix here would have to be to turn it into a non-isolated computed property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, makes sense 👍 Could also be a fixit i guess
actor A2: IsolatedWithNotSendableRequirements { | ||
nonisolated func f() -> NotSendable { NotSendable() } | ||
nonisolated var prop: NotSendable { NotSendable() } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so in this case we get warnings on A2().f()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't need warnings on A2().f()
because it doesn't cross any actor boundaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah because nonisolated, right... Thanks!
@swift-ci please smoke test |
When a non-isolated requirement is witnessed by an actor-isolated
witness, we are crossing into the actor. Ensure that we perform
Sendable checking across the actor boundary here.
Fixes rdar://80424675.