Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7300] nil converted to NSNull when returned from a nonnull Objective-C method #49848

swift-ci opened this issue Mar 28, 2018 · 1 comment


Copy link

@swift-ci swift-ci commented Mar 28, 2018

Previous ID SR-7300
Radar None
Original Reporter benpious (JIRA User)
Type Bug

Attachment: Download


Xcode Version 9.2 (9C40b).

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 76a08820f5a43a2ab494244c11a754e2

relates to:

  • SR-8622 Nonnull Objective-C property that falsely returns nil causes inconsistent Swift behavior

Issue Description:

If Swift code receives nil from a function declared in Objective-C which is marked as returning nonull, and the return value of that function is passed into an Objective-C function, that function will receive an instance of NSNull instead of nil, regardless of whether that function's parameter is annotated nonnull or nullable. In other words:

{{ let liar = Liar() // Implemented in Objective-C}}
{{ let obj = liar.totallyNotNull() // returns nil}}
{{ liar.takeNonNull(obj) // receives NSNull}}
{{ liar.takeNull(obj) // receives NSNull}}

Copy link

@belkadan belkadan commented Mar 29, 2018

I'm not sure we have any better options. @jckarter, any additional thoughts?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants