[Functions] Address more Swift 6 warnings #14772
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: module is not yet 100% Swift 6 compliant.
I added
@MainActor
so the compiler enforces that the completion handler can only be called on the main actor. This address the error in step 1.The new
@MainActor
attribute needed to bubble up to signature of a function that called the first one.HTTPSCallableResult
which is not Sendable, so sending it could cause data races.HTTPSCallableResult
as Sendable (it would have to be unchecked) because it retains anAny
. While our SDK could be audited to verify that it doesn't access theAny
reference, there'd be no way to enforce that it isn't accessed unsafely in SDK or client code.HTTPSCallableResult
issending
which indicates that it isn't accessed after being returned to the calling context.Task or actor isolated value cannot be sent
error in the above screenshot is tricky. The following fixes appear to address it. I think the issue is that we need to indicate that theAny
value is only owned in the current context. To do that, we markresponseDataJSON
to return asending Any
. MarkingFunctionsSerializer
asSendable
is the final piece. I'm less sure why it resolves it though? Previously, I addedsending
toFunctionsSerializer
'sdecode
API but that led to errors down a rabbit hole that I ultimately couldn't solve simply.#no-changelog