[swift-corelibs-dev] Foundation and explicit pointer nullability

Jordan Rose jordan_rose at apple.com
Fri Apr 1 11:20:54 CDT 2016


Hey, Philippe, everyone. I've been working on implementing SE-0055: Making pointer nullability explicit <https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md>, and it's been going well…but only now am I realizing how much it's going to affect Foundation, and possibly CF as well. While the nullability of APIs can usually be brought over from the Foundation headers, there are a lot of places where SwiftFoundation isn't clear about its nullability requirements within its implementation. For example, NSData appears to allow replacing a range of bytes with a {NULL, 0} buffer, but the implementation currently calls directly through to _CFDataReplaceBytes, which does not accept null pointers. (And if it were annotated to, it would then try to memmove from it, which is illegal.) The fix is trivial—just check for the null pointer case (or zero length case) and use an alternate API instead—but there might be quite a few of them.

I'm planning to run through all of Foundation (and XCTest) and get their tests passing using my branch of Swift <https://github.com/apple/swift/pull/1878>, then submit a pull request for review, to be landed in sync with the Swift change. Does that sound like the best plan to you?

Thanks,
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160401/a0db4437/attachment.html>


More information about the swift-corelibs-dev mailing list