Skip to content

Commit 424ebff

Browse files
authored
fix: remove all generic shadow warnings (#120)
1 parent e92241c commit 424ebff

File tree

9 files changed

+46
-39
lines changed

9 files changed

+46
-39
lines changed

CHANGELOG.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
# Parse-Swift Changelog
33

44
### main
5-
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.7.2...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift)
5+
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.7.3...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift)
66
* _Contributing to this repo? Add info about your change here to be included in the next release_
77

8+
### 5.7.2
9+
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.7.2...5.7.3), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.7.3/documentation/parseswift)
10+
11+
__Fixes__
12+
* Remove all generic shadow warnings in Swift 5.9 ([#120](https://github.com/netreconlab/Parse-Swift/pull/120)), thanks to [Corey Baker](https://github.com/cbaker6).
13+
814
### 5.7.2
915
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.7.1...5.7.2), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.7.2/documentation/parseswift)
1016

1117
__Fixes__
12-
* ParsePolygon encoding during a save and decoding resulted in (longitude, latitude) when it should be
13-
(latitude, longitude). If a developer used ParseSwift <= 5.7.1
14-
to save/update ParsePolygon's, they will need to update the respective ParseObjects by swapping the latitude
15-
and longitude manually. Deprecated withinPolygon() query constraint for geoPoint() and polygonContains() for
16-
polygon() ([#118](https://github.com/netreconlab/Parse-Swift/pull/118)), thanks to
17-
[Corey Baker](https://github.com/cbaker6).
18+
* ParsePolygon encoding during a save and decoding resulted in (longitude, latitude) when it should be (latitude, longitude). If a developer used ParseSwift <= 5.7.1 to save/update ParsePolygon's, they will need to update the respective ParseObjects by swapping the latitude and longitude manually. Deprecated withinPolygon() query constraint for geoPoint() and polygonContains() for polygon() ([#118](https://github.com/netreconlab/Parse-Swift/pull/118)), thanks to [Corey Baker](https://github.com/cbaker6).
1819

1920
### 5.7.1
2021
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.7.0...5.7.1), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.7.1/documentation/parseswift)

Sources/ParseSwift/API/API+Command.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,10 @@ internal extension API.Command {
401401
}
402402

403403
// MARK: Saving ParseObjects
404-
static func save<T>(_ object: T,
404+
static func save<V>(_ object: V,
405405
original data: Data?,
406406
ignoringCustomObjectIdConfig: Bool,
407-
batching: Bool = false) async throws -> API.Command<T, T> where T: ParseObject {
407+
batching: Bool = false) async throws -> API.Command<V, V> where V: ParseObject {
408408
if Parse.configuration.isRequiringCustomObjectIds
409409
&& object.objectId == nil && !ignoringCustomObjectIdConfig {
410410
throw ParseError(code: .missingObjectId, message: "objectId must not be nil")
@@ -417,77 +417,77 @@ internal extension API.Command {
417417
return try await create(object)
418418
}
419419

420-
static func create<T>(_ object: T) async throws -> API.Command<T, T> where T: ParseObject {
420+
static func create<V>(_ object: V) async throws -> API.Command<V, V> where V: ParseObject {
421421
var object = object
422422
if object.ACL == nil,
423423
let acl = try? await ParseACL.defaultACL() {
424424
object.ACL = acl
425425
}
426-
let mapper = { (data) -> T in
426+
let mapper = { (data) -> V in
427427
try ParseCoding.jsonDecoder().decode(CreateResponse.self, from: data).apply(to: object)
428428
}
429-
return API.Command<T, T>(method: .POST,
429+
return API.Command<V, V>(method: .POST,
430430
path: try await object.endpoint(.POST),
431431
body: object,
432432
mapper: mapper)
433433
}
434434

435-
static func replace<T>(_ object: T,
436-
original data: Data?) throws -> API.Command<T, T> where T: ParseObject {
435+
static func replace<V>(_ object: V,
436+
original data: Data?) throws -> API.Command<V, V> where V: ParseObject {
437437
guard object.objectId != nil else {
438438
throw ParseError(code: .missingObjectId,
439439
message: "objectId must not be nil")
440440
}
441-
let mapper = { (mapperData: Data) -> T in
441+
let mapper = { (mapperData: Data) -> V in
442442
var updatedObject = object
443443
updatedObject.originalData = nil
444444
updatedObject = try ParseCoding
445445
.jsonDecoder()
446446
.decode(ReplaceResponse.self, from: mapperData)
447447
.apply(to: updatedObject)
448448
guard let originalData = data,
449-
let original = try? ParseCoding.jsonDecoder().decode(T.self,
449+
let original = try? ParseCoding.jsonDecoder().decode(V.self,
450450
from: originalData),
451451
original.hasSameObjectId(as: updatedObject) else {
452452
return updatedObject
453453
}
454454
return try updatedObject.merge(with: original)
455455
}
456-
return API.Command<T, T>(method: .PUT,
456+
return API.Command<V, V>(method: .PUT,
457457
path: object.endpoint,
458458
body: object,
459459
mapper: mapper)
460460
}
461461

462-
static func update<T>(_ object: T,
463-
original data: Data?) throws -> API.Command<T, T> where T: ParseObject {
462+
static func update<V>(_ object: V,
463+
original data: Data?) throws -> API.Command<V, V> where V: ParseObject {
464464
guard object.objectId != nil else {
465465
throw ParseError(code: .missingObjectId,
466466
message: "objectId must not be nil")
467467
}
468-
let mapper = { (mapperData: Data) -> T in
468+
let mapper = { (mapperData: Data) -> V in
469469
var updatedObject = object
470470
updatedObject.originalData = nil
471471
updatedObject = try ParseCoding
472472
.jsonDecoder()
473473
.decode(UpdateResponse.self, from: mapperData)
474474
.apply(to: updatedObject)
475475
guard let originalData = data,
476-
let original = try? ParseCoding.jsonDecoder().decode(T.self,
476+
let original = try? ParseCoding.jsonDecoder().decode(V.self,
477477
from: originalData),
478478
original.hasSameObjectId(as: updatedObject) else {
479479
return updatedObject
480480
}
481481
return try updatedObject.merge(with: original)
482482
}
483-
return API.Command<T, T>(method: .PATCH,
483+
return API.Command<V, V>(method: .PATCH,
484484
path: object.endpoint,
485485
body: object,
486486
mapper: mapper)
487487
}
488488

489489
// MARK: Fetching ParseObjects
490-
static func fetch<T>(_ object: T, include: [String]?) throws -> API.Command<T, T> where T: ParseObject {
490+
static func fetch<V>(_ object: V, include: [String]?) throws -> API.Command<V, V> where V: ParseObject {
491491
guard object.objectId != nil else {
492492
throw ParseError(code: .missingObjectId,
493493
message: "objectId must not be nil")
@@ -498,12 +498,12 @@ internal extension API.Command {
498498
params = ["include": "\(Set(includeParams))"]
499499
}
500500

501-
return API.Command<T, T>(
501+
return API.Command<V, V>(
502502
method: .GET,
503503
path: object.endpoint,
504504
params: params
505-
) { (data) -> T in
506-
try ParseCoding.jsonDecoder().decode(T.self, from: data)
505+
) { (data) -> V in
506+
try ParseCoding.jsonDecoder().decode(V.self, from: data)
507507
}
508508
}
509509
}

Sources/ParseSwift/API/API+NonParseBodyCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ internal extension API {
113113
internal extension API.NonParseBodyCommand {
114114

115115
// MARK: Deleting
116-
static func delete<T>(_ object: T) throws -> API.NonParseBodyCommand<NoBody, NoBody> where T: ParseObject {
116+
static func delete<V>(_ object: V) throws -> API.NonParseBodyCommand<NoBody, NoBody> where V: ParseObject {
117117
guard object.isSaved else {
118118
throw ParseError(code: .otherCause,
119119
message: "Cannot delete an object without an objectId")

Sources/ParseSwift/LiveQuery/LiveQueryConstants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public enum Event<T: ParseObject>: Equatable {
4343
}
4444
}
4545

46-
public static func == <T>(lhs: Event<T>, rhs: Event<T>) -> Bool {
46+
public static func == <U>(lhs: Event<U>, rhs: Event<U>) -> Bool {
4747
switch (lhs, rhs) {
4848
case (.entered(let obj1), .entered(let obj2)): return obj1 == obj2
4949
case (.left(let obj1), .left(let obj2)): return obj1 == obj2

Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ public extension Query {
893893
- returns: Your subscription handler, for easy chaining.
894894
- throws: An error of type `ParseError`.
895895
*/
896-
static func subscribe<T: QuerySubscribable>(_ handler: T) async throws -> T {
896+
static func subscribe<V: QuerySubscribable>(_ handler: V) async throws -> V {
897897
try await ParseLiveQuery.client().subscribe(handler)
898898
}
899899

@@ -904,7 +904,7 @@ public extension Query {
904904
- returns: Your subscription handler, for easy chaining.
905905
- throws: An error of type `ParseError`.
906906
*/
907-
static func subscribe<T: QuerySubscribable>(_ handler: T, client: ParseLiveQuery) async throws -> T {
907+
static func subscribe<V: QuerySubscribable>(_ handler: V, client: ParseLiveQuery) async throws -> V {
908908
try await ParseLiveQuery.client().subscribe(handler)
909909
}
910910

@@ -957,7 +957,7 @@ public extension Query {
957957
- parameter handler: The specific handler to unsubscribe from.
958958
- throws: An error of type `ParseError`.
959959
*/
960-
func unsubscribe<T: QuerySubscribable>(_ handler: T) async throws {
960+
func unsubscribe<V: QuerySubscribable>(_ handler: V) async throws {
961961
try await ParseLiveQuery.client().unsubscribe(handler)
962962
}
963963

@@ -968,7 +968,7 @@ public extension Query {
968968
- parameter client: A specific client.
969969
- throws: An error of type `ParseError`.
970970
*/
971-
func unsubscribe<T: QuerySubscribable>(_ handler: T, client: ParseLiveQuery) async throws {
971+
func unsubscribe<V: QuerySubscribable>(_ handler: V, client: ParseLiveQuery) async throws {
972972
try await client.unsubscribe(handler)
973973
}
974974
}
@@ -981,7 +981,7 @@ public extension Query {
981981
- parameter handler: The specific handler to update.
982982
- throws: An error of type `ParseError`.
983983
*/
984-
func update<T: QuerySubscribable>(_ handler: T) async throws {
984+
func update<V: QuerySubscribable>(_ handler: V) async throws {
985985
try await ParseLiveQuery.client().update(handler)
986986
}
987987

@@ -992,7 +992,7 @@ public extension Query {
992992
- parameter client: A specific client.
993993
- throws: An error of type `ParseError`.
994994
*/
995-
func update<T: QuerySubscribable>(_ handler: T, client: ParseLiveQuery) async throws {
995+
func update<V: QuerySubscribable>(_ handler: V, client: ParseLiveQuery) async throws {
996996
try await client.update(handler)
997997
}
998998
}

Sources/ParseSwift/ParseConstants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010

1111
enum ParseConstants {
1212
static let sdk = "swift"
13-
static let version = "5.7.2"
13+
static let version = "5.7.3"
1414
static let fileManagementDirectory = "parse/"
1515
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
1616
static let fileManagementLibraryDirectory = "Library/"

Sources/ParseSwift/Types/ParseServer+async.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public extension ParseServer {
5050
- parameter options: A set of header options sent to the server. Defaults to an empty set.
5151
- returns: Status of ParseServer.
5252
- throws: An error of type `ParseError`.
53+
- requires: `.usePrimaryKey` has to be available. It is recommended to only
54+
use the primary key in server-side applications where the key is kept secure and not
55+
exposed to the public.
5356
*/
5457
static func information(options: API.Options = []) async throws -> Information {
5558
try await withCheckedThrowingContinuation { continuation in

Sources/ParseSwift/Types/ParseServer+combine.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public extension ParseServer {
4949
Retrieves any information provided by the server *asynchronously*. Publishes when complete.
5050
- parameter options: A set of header options sent to the server. Defaults to an empty set.
5151
- returns: A publisher that eventually produces a single value and then finishes or fails.
52+
- requires: `.usePrimaryKey` has to be available. It is recommended to only
53+
use the primary key in server-side applications where the key is kept secure and not
54+
exposed to the public.
5255
*/
5356
static func informationPublisher(options: API.Options = []) -> Future<Information, ParseError> {
5457
Future { promise in

Sources/ParseSwift/Types/Query.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public struct Query<T>: ParseTypeable where T: ParseObject {
4646
Self.className
4747
}
4848

49-
struct AggregateBody<T>: Codable where T: ParseObject {
49+
struct AggregateBody<V>: Codable where V: ParseObject {
5050
let pipeline: [[String: AnyCodable]]?
5151
let hint: AnyCodable?
5252
let explain: Bool?
5353
let includeReadPreference: String?
5454

55-
init(query: Query<T>) {
55+
init(query: Query<V>) {
5656
pipeline = query.pipeline
5757
hint = query.hint
5858
explain = query.explain
@@ -77,13 +77,13 @@ public struct Query<T>: ParseTypeable where T: ParseObject {
7777
}
7878
}
7979

80-
struct DistinctBody<T>: Codable where T: ParseObject {
80+
struct DistinctBody<V>: Codable where V: ParseObject {
8181
let hint: AnyCodable?
8282
let explain: Bool?
8383
let includeReadPreference: String?
8484
let distinct: String?
8585

86-
init(query: Query<T>) {
86+
init(query: Query<V>) {
8787
distinct = query.distinct
8888
hint = query.hint
8989
explain = query.explain

0 commit comments

Comments
 (0)