-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[interop][SwiftToCxx] add support for exposing non-isolated actor declarations #61882
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
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test source compatibility |
1 similar comment
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test source compatibility |
|
||
public nonisolated func method() { | ||
print("nonisolated method") | ||
} |
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 wonder if you'd also want to add a
public nonisolated func methodAsync() async
and confirm it does not import; though I guess this perhaps is already handled -- it's the same as any normal async function after all.
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.
async functions are not bridged already, we cover that. But I can add as a follow-up!
distributed public func dist() {} | ||
|
||
@_expose(Cxx) // ok | ||
public init() { |
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.
public init() { | |
public init(actorSystem: LocalTestingDistributedActorSystem) { | |
self.actorSystem = actorSystem |
is what you'd need to do to make sure this is a 100% correct actor; this should have failed to compile tbh as it is declared now - but the other errors probably prevented it from going into those checks
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.
Sounds good, I'll commit this as a follow-up!
} | ||
|
||
@_expose(Cxx) | ||
public distributed actor DistributedActorClass { |
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.
Hooray! Semantics look good 👍
return {Unsupported, UnrepresentableActorClass}; | ||
} | ||
if (getActorIsolation(const_cast<ValueDecl *>(VD)).isActorIsolated()) | ||
return {Unsupported, UnrepresentableIsolatedInActor}; |
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.
awesome, glad that this indeed covered all the bases :-)
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.
LGTM! Might want to add a test with nonisolated + async
method too though
@swift-ci please test macOS platform |
1 similar comment
@swift-ci please test macOS platform |
source compatibility suite failures are unrelated, will merge:
|
This exposes Swift actor classes to C++. Only non-isolated declarations get bridged to C++ though.