When an NSArray is force-downcast to T[] at an API boundary, we need to
remember that each element needs to be dynamically checked when
accessed. No deferred casts are being generated yet, so NFC
Swift SVN r18243
Turns out we really want to use reinterpretCast when we know it will
work, rather than a checked downcast + forced optional unwrapping. The
latter will only be as fast as the former in -Ofast
Swift SVN r18241
assert() and fatalError()
These functions are meant to be used in user code. They are enabled in debug
mode and disabled in release or fast mode.
_precondition() and _preconditionFailure()
These functions are meant to be used in library code to check preconditions at
the api boundry. They are enabled in debug mode (with a verbose message) and
release mode (trap). In fast mode they are disabled.
_debugPrecondition() and _debugPreconditionFailure()
These functions are meant to be used in library code to check preconditions that
are not neccesarily comprehensive for safety (UnsafePointer can be null or an
invalid pointer but we can't check both). They are enabled only in debug mode.
_sanityCheck() and _fatalError()
These are meant to be used for internal consistency checks. They are only
enabled when the library is build with -DSWIFT_STDLIB_INTERNAL_CHECKS=ON.
I modified the code in the standard library to the best of my judgement.
rdar://16477198
Swift SVN r18212
The _native computed property that backs this method has a different
contract than requestNativeBuffer() expected: it returned an empty
buffer rather than using an optional and returning nil. We were just
wrapping up that empty buffer and declaring success, which meant we
would bridge from an NSArray wrapping native storage of T to an empty
native array, always.
This change is a necessary prerequisite to importing NSArray* as
(AnyObject[])! per <rdar://problem/16535097>. That (imminent) change
tests this, but we need more targetted testing of this area.
Swift SVN r18143