Skip to content

[rbi] Lookthrough an invocation of DistributedActor.asLocalActor when determining actor instances. #81909

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

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jun 2, 2025

In this case, what is happening is that in SILGen, we insert implicit DistributedActor.asLocalActor calls to convert a distributed actor to its local any Actor typed form. The intention is that the actor parameter and result are considered the same... but there is nothing at the SIL level to enforce that. In this commit, I change ActorInstance (the utility that defines actor identity at a value level) to look through such a call.

I implemented this by just recognizing the decl directly. We already do this in parts of SILGen, so I don't really see a problem with doing this. It also provides a nice benefit that we do not have to modify SILFunctionType to represent this or put a @_semantic attribute on the getter.

NOTE: Generally, Sema prevents us from mixing together different actors. In this case, Sema does not help us since this call is inserted implicitly by the distributed actor implementation in SILGen. So this is not a problem in general.

rdar://152436817

… determining actor instances.

In this case, what is happening is that in SILGen, we insert implicit
DistributedActor.asLocalActor calls to convert a distributed actor to its local
any Actor typed form. The intention is that the actor parameter and result are
considered the same... but there is nothing at the SIL level to enforce that. In
this commit, I change ActorInstance (the utility that defines actor identity at
a value level) to look through such a call.

I implemented this by just recognizing the decl directly. We already do this in
parts of SILGen, so I don't really see a problem with doing this. It also
provides a nice benefit that we do not have to modify SILFunctionType to
represent this or put a @_semantic attribute on the getter.

NOTE: Generally, Sema prevents us from mixing together different actors. In this
case, Sema does not help us since this call is inserted implicitly by the
distributed actor implementation in SILGen. So this is not a problem in general.

rdar://152436817
@gottesmm gottesmm requested review from ktoso and eeckstein as code owners June 2, 2025 19:22
@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 2, 2025

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 2, 2025

@ktoso as requested = )

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, that's a great noninvasive solution. Thanks @gottesmm, lgtm!

@gottesmm gottesmm enabled auto-merge June 2, 2025 22:33
@gottesmm gottesmm merged commit 7d82d72 into swiftlang:main Jun 3, 2025
3 checks passed
@gottesmm gottesmm deleted the pr-775f782ff711827a2a0dce73a522b6eb9bc2d484 branch June 3, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants