Skip to content

Commit

Permalink
[swift5] fix compile error from Alamofire 5.10 - cast Parameter type …
Browse files Browse the repository at this point in the history
…to avoid recursion (#19908)

* cast type to avoid unintended recursive call

* update samples
  • Loading branch information
rmustard authored Oct 18, 2024
1 parent c6dbf08 commit 1248d7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ extension JSONDataEncoding: ParameterEncoding {
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
let urlRequest = try urlRequest.asURLRequest()
return encode(urlRequest, with: parameters)
// Alamofire 5.10 changed type of Parameters so that it is no longer equivalent to [String: Any]
// cast this type so that the call to encode is not recursive
return encode(urlRequest, with: parameters as [String: Any]?)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ extension JSONDataEncoding: ParameterEncoding {
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
let urlRequest = try urlRequest.asURLRequest()

return encode(urlRequest, with: parameters)
// Alamofire 5.10 changed type of Parameters so that it is no longer equivalent to [String: Any]
// cast this type so that the call to encode is not recursive
return encode(urlRequest, with: parameters as [String: Any]?)
}
}

0 comments on commit 1248d7a

Please sign in to comment.