Skip to content

[SR-2444] @escaping failing on optional blocks #45049

@gonzalolarralde

Description

@gonzalolarralde
Previous ID SR-2444
Radar None
Original Reporter @gonzalolarralde
Type Bug
Status Resolved
Resolution Done
Environment

Ubuntu 16.04
swift-master @ HEAD:a23bb43d7141599786e45a75876c995611073e45

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee @milseman
Priority Medium

md5: e30e726be4270da7c451adbc31564015

duplicates:

Issue 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.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions