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
Really we want those nullary functions be computed properties using enums.
var _assertConfiguration : _AssertConfiguration {
let assertConfig = Int32(Builtin.assert_configuration())
if assertConfig == 0 {
return .Debug
}
if assertConfig == 1 {
return .Release
}
return .Fast
}
if _assertConfiguration == .Debug {
_fatal_error_message("assertion failed", message, file, line)
}
In my tests the enums were not optimized away. So for the short term leave
these functions as nullary functions.
Swift SVN r18211
Prior to this fix this would fail:
(swift) import Foundation
(swift) extension NSDate { func foo() { println("foo") }}
As the Class for NSDate was not initialized.
<rdar://problem/16934080>
Swift SVN r18206
I've never used 'newlocale' before, so I may be using it wrong.
Also, this may not be 100% thread safe; worst case we create
multiple locale objects when swift_doubleToString() is called
at the same time. We can fix this if we care.
Swift SVN r18201
creating a Dictionary from a dictionary literal
Also fixes rdar://16876745, because once the code moved to using lower-level
interfaces, it became trivial to detect duplicate keys without a performance
hit.
Swift SVN r18193
... unless we actually hit one of the confusing cases involving
multi-dimensional arrays (e.g., Int[]?[]), at which point one needs to
write parentheses <rdar://problem/16737035>.
Swift SVN r18181
We decided that classes and Objective-C existentials are always going
to be bridged verbatim, ignoring any _BridgedToObjectiveC conformances.
While the compiler isn't preventing conformance of a class type to
_BridgedToObjectiveC, we ignore this case and will find a way to lock
it down if _BridgedToObjectiveC loses its underscore.
The motivation here is that (1) we don't really have a use case for a
class that bridges to Objective-C in any way other than just being an
Objective-C class, and (2) the class-or-ObjC-existential check is
ridiculously cheap compared to the
thread-safe-hash-table-over-a-dlsym-call used to find witness tables,
so do the cheap, common check first.
Swift SVN r18177
Once we know that the storage is contiguous we use the new API _NthContiguous.
We can further optimize this code by specializing the access to ascii or UTF-16.
Swift SVN r18167
This method returns a proxy object. Swift cannot current cast proxy objects
to their proxied types. The workaround for now is to add a generic overlay
for -prepareWithInvocationTarget: so the declared type of the returned
proxy is the proxied type. This is good enough to make undo proxies work with
objc-dispatched calls.
Swift SVN r18155
I suspect this can be made much better. It only
works for comparing Array<T> and Array<T>,
NativeArray<T> and NativeArray<T>, etc., not
NativeArray<T> and Array<T>. I also suspect
the implementation can be made better. The goal
was to make this functional, as this basic
functionality was missing.
Implements <rdar://problem/16768095>.
Swift SVN r18150
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
The code is incorrect and depends on functions introduced in this year's OSs.
Additionally, CoreImage is a top-level framework on iOS, so we have to be
more careful if/when we add this back.
Swift SVN r18135
This is a better solution to <rdar://problem/16899681> because the
runtime magic is limited to implementing the witnesses of this
conformance.
The type checker fixes are because we can end up using unchecked
optionals in more places, via bridging, than we could before.
Swift SVN r18120
Empty NSArrays are usually represented by emptyNSSwiftArray, whose
element type is irrelevant. So when doing a getObjects:range: on that,
presumably the range's length is zero and we shouldn't do any sanity
checking w.r.t. the element type.
Fixes <rdar://problem/16914909> Assertion failed attempting to append
arrays when subclassing Cocoa class
Swift SVN r18110