Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
Description
When building the driver in Swift 4.1+, one gets several deprecation warnings like this:
/Users/kaitlinmahar/mongo-swift-driver/Sources/MongoSwift/BSON/Document.swift:322:22: warning: 'deallocate(capacity:)' is deprecated: Swift currently only supports freeing entire heap blocks, use deallocate() instead |
document.deallocate(capacity: 1) |
I am pretty sure that the new way will not work in 4.0, but we should confirm that. It seems that Xcode 10 + swiftenv's 4.0 are not playing nicely together and I can no longer build the driver with 4.0 locally to test myself...
Assuming it doesn't work with 4.0, we can fix these warnings by using inline version checks, that use the new way for Swift 4.1+. See _BSONKeyedDecodingContainer.allKeys for an example of an inline version check.
It appears that all of these cases involve an UnsafeMutablePointer<UnsafePointer<Int8>?> or an UnsafeMutablePointer<UnsafePointer<bson_t>?>, so we can likely accomplish this using 1-2 shared methods that handle freeing pointer pointers, rather than adding the conditional in every place.
Attachments
Issue Links
- related to
-
SWIFT-235 Fix UnsafeMutableRawPointer! deprecation warnings in Swift 4.1+
-
- Closed
-