-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Distributed] Fix too restrictive distributed witness isolation checking #59358
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
Conversation
I did tests with working around the limitation of actor isolation with generics -- once #59356 is done we can undo the hack here 👍 |
@swift-ci please smoke test |
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.
Looks okay, but I think it can be simplified somewhat.
lib/Sema/TypeCheckProtocol.cpp
Outdated
|
||
// If we're coming from a non-distributed requirement, | ||
// then the requirement must be 'throws' to accommodate failure. | ||
if (!isDistributedDecl(requirement) && !isThrowsDecl(requirement)) |
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.
We can't have distributed requirements outside of DistributedActor-based protocols, right? So we don't need this isDistributedDecl
check?
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.
Or did you mean isDistributedDecl(witness)
?
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.
I revisited this all, added more tests and simplified: 8e6d721
Thank you! I'll dig into the comments 🙏 |
@swift-ci please smoke test and merge |
Resolves rdar://94779780
Blocked by: #59356
Distributed witness checking is implemented in order to avoid "peeling off" the distributed-ness from a distributed actor.
We cannot allow upcasting a DA to some arbitrary
protocol P
, where thatprotocol P
requirement isn't async + throws, because cross-actor calls must always have this effect.We missed to handle an edge case in the model, which is requirements declared on a
protocol DAP: DistributedActor
which is where we CANNOT "peel off" the distributedness off the distributed actor, by upcasting it to that DAP.Errors forcing us to adopt
nonisolated
ordistributed
for this method; while it is strictly speaking not necessary.We CAN witness this method, but it will be impossible to call when erased to
WatchingDA
because distributed actor isolation will prevent it from being called (!),and this is exactly what we want. To only be able to call "inside" or "when known to be local", which is how frameworks can implement their lifecycle management hooks.
Example:
In practice this missing checking rule caused us to have to write such terrible workarounds: