Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-234

Fix deallocate deprecation warnings in Swift 4.1+

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 0.0.8
    • 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

          Activity

            People

              kaitlin.mahar@mongodb.com Kaitlin Mahar
              kaitlin.mahar@mongodb.com Kaitlin Mahar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: