Skip to content
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

feat: address concurrency warnings arising from Theme #387

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cweider
Copy link

@cweider cweider commented Feb 12, 2025

Theme was marked as Sendable in #351. There's nothing wrong with this per se, but sendability is not inferred for public types, a structure is only truely Sendable if all of its members are Sendable, and most of the members of Theme are not Sendable.

This patch address the sendability warnings for Theme's members that the compiler emits (regardless of StrictConcurrency).

`Theme` was marked as `Sendable` in gonzalezreal#351. There's nothing wrong
with this per se, but sendability is not inferred for public
types, a structure is only truely `Sendable` if all of its
members are `Sendable`, and most of the members of `Theme` are
not `Sendable`.

This patch address the sendability warnings for Theme's members
that the compiler emits (regardless of `StrictConcurrency`).
@cweider
Copy link
Author

cweider commented Feb 12, 2025

This patch is distinguishable from #349 in that it addresses the warnings, triggered by Theme being sendable, that are in the project as-is. It doesn’t make any attempt to address larger issue of complying with strict concurrency.

public struct BlockStyle<Configuration> {
private let body: (Configuration) -> AnyView
public struct BlockStyle<Configuration> : Sendable {
private let body: @Sendable (Configuration) -> AnyView
Copy link
Author

@cweider cweider Feb 12, 2025

Choose a reason for hiding this comment

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

There’s a whole followup chunk of work needed to make initializers (and so on) provide a @Sendable. The functions, producing View should be bound to the @MainActor as well.

You can see that at fe5621b7af. It could be squashed onto this change or pushed later.

@cweider
Copy link
Author

cweider commented Feb 12, 2025

Well, this snowballed a bit – only a little extra work needed to clear out the warnings and enable StrictConcurrency. A branch doing this is posted at cweider:swift-markdown-ui:concurrency-strict. Let me know how you might want to go about releasing those changes.

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.

1 participant