-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Distributed] decode init for DistributedActor #38998
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
selfAccess = SelfAccessKind::Mutating; | ||
} | ||
} | ||
} |
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 this only is enabled specifically for this single initializer in distributed actors; at least until we do an SE pitch for it.
onlyUseIsValueMetatype = false; | ||
break; | ||
} | ||
if (onlyUseIsValueMetatype) { |
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 only other bit we need to enable this AFAIK
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.
This is lifted directly from [awaiting evolution] Allow convenience initializers to reassign self. #19311
@available(SwiftStdlib 5.5, *) | ||
static let actorTransportKey = CodingUserInfoKey(rawValue: "$dist_act_transport")! | ||
@available(SwiftStdlib 5.5, *) | ||
public static let actorTransportKey = CodingUserInfoKey(rawValue: "$dist_act_transport")! |
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.
this was a nasty omission! made sample apps impossible.
} | ||
|
||
let id: AnyActorIdentity = try transport.decodeIdentity(from: decoder) | ||
self = try Self.resolve(id, using: transport) |
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 reason why we need the initializer semantics change.
@@ -121,12 +126,14 @@ public protocol ActorIdentity: Sendable, Hashable, Codable {} | |||
|
|||
@available(SwiftStdlib 5.5, *) | |||
public struct AnyActorIdentity: ActorIdentity, @unchecked Sendable, CustomStringConvertible { | |||
public let underlying: Any |
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.
this is important, impls need to be able to reach this.
@swift-ci please smoke test |
@swift-ci please build toolchain |
Linux Toolchain (Ubuntu 16.04) Install command |
…st-resolve" (swiftlang#38994)" This reverts commit f6ae9f3.
TODO: SILOptimizer/definite_init_value_types_diagnostics.swift |
1e69600
to
c9a4614
Compare
c9a4614
to
c6da297
Compare
Ok excellent, this works without any changes in DI actually. So it is fully isolated to the specific distributed actor initializer, therefore - going ahead with merging. |
c6da297
to
6fe7f1f
Compare
@swift-ci please smoke test |
resolves rdar://70858677 by implementing the
init(from:)
Decodable bit in AST for the distributed actor protocol.We're actually able to implement this in AST but only because of the note below. It would be a pain to implement in SIL and I think we should move forward with proposing the below feature as SE anyway.
Note:
This needed to enable the
self = ...
assignment in specifically this single initializer so we can unblock our progress here for now; The general concept we could enable in general and @jckarter worked on this before here:This was discussed a few years ago and deserves it's own Swift Evolution proposal to enable "in general": https://forums.swift.org/t/allow-self-x-in-class-convenience-initializers/15924