Uploaded image for project: 'Swift'
  1. Swift
  2. SR-2444

@escaping failing on optional blocks

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      Ubuntu 16.04
      swift-master @ HEAD:a23bb43d7141599786e45a75876c995611073e45

      Description

      @escaping doesn't seem to be working on Optional block parameters.

      This is related to SR-2166, but in that case being the default @escaping a safer option than @noescape the workaround was to let it @escaping.

      swift-corelibs-libdispatch/src/swift/Private.swift:72:116: error: @escaping may only be applied to parameters of function type
      public func dispatch_data_create(_ buffer: UnsafeRawPointer, _ size: Int, _ queue: DispatchQueue?, _ destructor: (@escaping () -> Void)?) -> dispatch_data_t
                                                                                                                        ~^~~~~~~~~
      
      swift-corelibs-libdispatch/src/swift/Wrapper.swift:216:83: error: @escaping may only be applied to parameters of function type
              func setCancelHandler(qos: DispatchQoS, flags: DispatchWorkItemFlags, handler: (@escaping DispatchSourceHandler)?)
                                                                                              ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      

      Expected result:

      @escaping optional blocks should compile.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                milseman Michael Ilseman
                Reporter:
                gonzalolarralde Gonzalo Larralde
              • Votes:
                1 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: