Skip to content

[3.0] Handle inaccurate ObjC nullability in id-as-Any bridging. #4387

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

Merged
merged 2 commits into from
Aug 19, 2016

Conversation

jckarter
Copy link
Contributor

Make id-as-Any bridging resilient against ObjC APIs that claim to be _Nonnull but produce nil in practice, by wrapping up nils as AnyObject?s-inside-Anys instead of as invalid AnyObjects-inside-Anys. rdar://problem/27874026

We want to be robust against unexpected `nil`s when bringing `id`s into Swift as `Any`. Add a function that builds an AnyObject?-in-an-Any when we unexpectedly receive a nil.
Bitcast the AnyObject result to AnyObject?, then call our new helper function, so that we can handle nils without choking. Fixes rdar://problem/27874026.
@jckarter
Copy link
Contributor Author

@swift-ci Please test macOS

@tkremenek tkremenek self-assigned this Aug 18, 2016
@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 105fcd9
Test requested by - @jckarter

@jckarter
Copy link
Contributor Author

Test failure is in swiftpm; looks unrelated:

17:20:38 
/Users/buildnode/jenkins/workspace/swift-PR-osx/branch-swift-3.0-branch/swiftpm/Sources/Basic/Thread.swift:50:33: error: extraneous argument label 'block:' in call
17:20:38         self.thread = ThreadImpl(block: theTask)
17:20:38                                 ^~~~~~~~

cc @ddunbar

@tkremenek
Copy link
Member

@swift-ci test macOS

@ematejska ematejska merged commit 338f75a into swiftlang:swift-3.0-branch Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants