Skip to content

@objc async method has _Nonnull completion handler parameter instead of _Nullable #64870

Open
@fumoboy007

Description

@fumoboy007

Description
SE-0297 says that

@objc func perform(operation: String) async -> Int { ... }

will be translated into

- (void)performWithOperation:(NSString * _Nonnull)operation
           completionHandler:(void (^ _Nullable)(NSInteger))completionHandler;

However, when I tried it, the completion handler is _Nonnull, resulting in the following warning when I try to pass nil:

Null passed to a callee that requires a non-null argument

Steps to reproduce
See the above sample code.

Expected behavior
Passing nil to the completion handler parameter should not produce a warning.

Environment

  • Swift compiler version info:
swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: x86_64-apple-macosx12.0
  • Xcode version info:
Xcode 14.2
Build version 14C18
  • Deployment target: iOS 16.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    @objcFeature → attributes: The @objc attributeSILGenArea → compiler: The SIL generation stageasync & awaitFeature → concurrency: asynchronous function aka the async/await patternattributesFeature: Declaration and type attributesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresobjective-c interopFeature: Interoperability with Objective-Cswift 5.7unexpected behaviorBug: Unexpected behavior or incorrect output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions