Skip to content

[Distributed] Implicit Codable conformance for distributed actors #41727

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 3 commits into from
Mar 11, 2022

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Mar 8, 2022

Codable conformance is synthesized for any concrete DistributedActor when the ID it has is Codable.

This would not be implementable in "normal" swift due to the need to assign to self in the initializer.

@ktoso ktoso added the distributed Feature → concurrency: distributed actor label Mar 8, 2022
@ktoso ktoso force-pushed the wip-implicit-codable branch 4 times, most recently from 6bca6b2 to 3ee81e0 Compare March 9, 2022 07:17
@ktoso
Copy link
Contributor Author

ktoso commented Mar 9, 2022

So we have the conformance in place but I can't figure out where or how to ensure the witness symbols get emitted

Undefined symbols for architecture arm64:
  "_$s4main6WorkerCSEAAMc", referenced from:
      _$s4main6WorkerCACSEAAWl in distributed_actor_encode_roundtrip-3b6d09.o
  "_$s4main6WorkerCSeAAMc", referenced from:
      _$s4main6WorkerCACSeAAWl in distributed_actor_encode_roundtrip-3b6d09.o
ld: symbol(s) not found for architecture arm64
Undefined symbols for architecture arm64:
  "protocol conformance descriptor for main.Worker : Swift.Encodable in main", referenced from:
      lazy protocol witness table accessor for type main.Worker and conformance main.Worker : Swift.Encodable in main in distributed_actor_encode_roundtrip-3b6d09.o
  "protocol conformance descriptor for main.Worker : Swift.Decodable in main", referenced from:
      lazy protocol witness table accessor for type main.Worker and conformance main.Worker : Swift.Decodable in main in distributed_actor_encode_roundtrip-3b6d09.o

Technically we have the

@available(SwiftStdlib 5.7, *)
extension DistributedActor /*: implicitly Encodable */ where Self.ID: Encodable {
  nonisolated public func encode(to encoder: Encoder) throws {

so i was hoping to not have to do anything extra but that does not seem to be the case.

I tried setting the witness when we create the conformance explicitly as well but that does no good either.

We cannot find the above extension on the protocol either because getExtensions() returns nothing since we're too early so we can't grab the impl from the extension on DistributedActor either way... I'd be ok to synthesize it if we have to, but when I tried this does not seem to solve the missing symbol anyway.

@ktoso ktoso force-pushed the wip-implicit-codable branch from 3ee81e0 to a8d5ce4 Compare March 10, 2022 04:12
@ktoso ktoso changed the title [WIP] Implicit Codable conformance for distributed actors [Distributed] Implicit Codable conformance for distributed actors Mar 10, 2022
@ktoso ktoso force-pushed the wip-implicit-codable branch from a8d5ce4 to d635bf0 Compare March 10, 2022 15:02
@ktoso
Copy link
Contributor Author

ktoso commented Mar 10, 2022

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Mar 10, 2022

Rebased :)

@ktoso ktoso force-pushed the wip-implicit-codable branch 2 times, most recently from f82f6d5 to 5ced12f Compare March 11, 2022 03:14
@ktoso ktoso requested review from DougGregor and xedin March 11, 2022 03:17
@ktoso
Copy link
Contributor Author

ktoso commented Mar 11, 2022

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Mar 11, 2022

Actual issue, fixing it.

  • Swift(linux-x86_64) :: Concurrency/require-explicit-sendable.swift
    • was a real issue, fixed
  • Swift(linux-x86_64) :: IDE/complete_actorisolation.swift
  • Swift(linux-x86_64) :: IDE/complete_diagnostics_concurrency.swift
  • seem just flaky...?

@ktoso
Copy link
Contributor Author

ktoso commented Mar 11, 2022

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Mar 11, 2022

Only reason this failed was because #41602 got merged in between...
Some new errors are reported by the combination of the two heh.

@ktoso ktoso force-pushed the wip-implicit-codable branch from debb63b to e4252a0 Compare March 11, 2022 09:34
@ktoso ktoso force-pushed the wip-implicit-codable branch from e4252a0 to fab0463 Compare March 11, 2022 09:46
@ktoso
Copy link
Contributor Author

ktoso commented Mar 11, 2022

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 59b9794 into swiftlang:main Mar 11, 2022
@ktoso ktoso deleted the wip-implicit-codable branch March 11, 2022 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Feature → concurrency: distributed actor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants