Skip to content

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

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

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jun 3, 2025

Explanation: This PR makes it so that when identifying actor instances we look through DistributedActor.asLocalActor. The reason why we need to do this 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.

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.

Scope: This just changes how we handle in SIL a specific call inserted by the distributed runtime. Will not impact any other code.

Resolves: rdar://152436817

Main PR: #81909

Risk: Low. This only changes how we handle in SIL a specific call inserted by the distributed runtime. Any other code will not be impacted by this change.

Testing: Added compiler tests

Reviewer: @ktoso

… 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
(cherry picked from commit 331626e)
@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 3, 2025

@swift-ci test

@gottesmm gottesmm marked this pull request as ready for review June 3, 2025 21:04
@gottesmm gottesmm requested a review from a team as a code owner June 3, 2025 21:04
@gottesmm gottesmm enabled auto-merge June 3, 2025 21:05
@gottesmm gottesmm merged commit 7fb85a3 into swiftlang:release/6.2 Jun 4, 2025
5 checks passed
@gottesmm gottesmm deleted the release/6.2-rdar152436817 branch June 4, 2025 12:33
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.

3 participants