Skip to content

[Functions] Address more Swift 6 warnings #14772

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 1 commit into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions FirebaseFunctions/Sources/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,15 @@ enum FunctionsConstants {
withObject data: Any?,
options: HTTPSCallableOptions?,
timeout: TimeInterval,
completion: @escaping ((Result<HTTPSCallableResult, Error>) -> Void)) {
completion: @escaping @MainActor (Result<HTTPSCallableResult, Error>) -> Void) {
// Get context first.
contextProvider.getContext(options: options) { context, error in
// Note: context is always non-nil since some checks could succeed, we're only failing if
// there's an error.
if let error {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
} else {
self.callFunction(url: url,
withObject: data,
Expand All @@ -459,7 +461,7 @@ enum FunctionsConstants {
options: HTTPSCallableOptions?,
timeout: TimeInterval,
context: FunctionsContext,
completion: @escaping ((Result<HTTPSCallableResult, Error>) -> Void)) {
completion: @escaping @MainActor (Result<HTTPSCallableResult, Error>) -> Void) {
let fetcher: GTMSessionFetcher
do {
fetcher = try makeFetcher(
Expand Down Expand Up @@ -762,7 +764,7 @@ enum FunctionsConstants {
}

private func callableResult(fromResponseData data: Data,
endpointURL url: URL) throws -> HTTPSCallableResult {
endpointURL url: URL) throws -> sending HTTPSCallableResult {
let processedData = try processedData(fromResponseData: data, endpointURL: url)
let json = try responseDataJSON(from: processedData)
let payload = try serializer.decode(json)
Expand All @@ -784,7 +786,7 @@ enum FunctionsConstants {
return data
}

private func responseDataJSON(from data: Data) throws -> Any {
private func responseDataJSON(from data: Data) throws -> sending Any {
let responseJSONObject = try JSONSerialization.jsonObject(with: data)

guard let responseJSON = responseJSONObject as? NSDictionary else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension FunctionsSerializer {
}
}

final class FunctionsSerializer {
final class FunctionsSerializer: Sendable {
// MARK: - Internal APIs

func encode(_ object: Any) throws -> Any {
Expand Down
Loading