Skip to content

Commit fea7aeb

Browse files
committed
Switch Foundation _sanityChecks to assertions
1 parent 776b33b commit fea7aeb

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

stdlib/public/SDK/Foundation/ExtraStringAPIs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension String.UTF16View.Index {
1515
@available(swift, deprecated: 3.2)
1616
@available(swift, obsoleted: 4.0)
1717
public init(_ offset: Int) {
18-
precondition(offset >= 0, "Negative UTF16 index offset not allowed")
18+
assert(offset >= 0, "Negative UTF16 index offset not allowed")
1919
self.init(encodedOffset: offset)
2020
}
2121

stdlib/public/SDK/Foundation/NSArray.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extension Array : _ObjectiveCBridgeable {
3131
/// The provided `NSArray` will be copied to ensure that the copy can
3232
/// not be mutated by other code.
3333
internal init(_cocoaArray: NSArray) {
34-
precondition(_isBridgedVerbatimToObjectiveC(Element.self),
34+
assert(_isBridgedVerbatimToObjectiveC(Element.self),
3535
"Array can be backed by NSArray only when the element type can be bridged verbatim to Objective-C")
3636
// FIXME: We would like to call CFArrayCreateCopy() to avoid doing an
3737
// objc_msgSend() for instances of CoreFoundation types. We can't do that

stdlib/public/SDK/Foundation/NSDictionary.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension Dictionary {
3535
/// The provided `NSDictionary` will be copied to ensure that the copy can
3636
/// not be mutated by other code.
3737
public init(_cocoaDictionary: _NSDictionary) {
38-
precondition(
38+
assert(
3939
_isBridgedVerbatimToObjectiveC(Key.self) &&
4040
_isBridgedVerbatimToObjectiveC(Value.self),
4141
"Dictionary can be backed by NSDictionary storage only when both key and value are bridged verbatim to Objective-C")
@@ -228,8 +228,8 @@ extension NSDictionary {
228228
let alignment = MemoryLayout<AnyObject>.alignment
229229
let singleSize = stride * numElems
230230
let totalSize = singleSize * 2
231-
precondition(stride == MemoryLayout<NSCopying>.stride)
232-
precondition(alignment == MemoryLayout<NSCopying>.alignment)
231+
assert(stride == MemoryLayout<NSCopying>.stride)
232+
assert(alignment == MemoryLayout<NSCopying>.alignment)
233233

234234
// Allocate a buffer containing both the keys and values.
235235
let buffer = UnsafeMutableRawPointer.allocate(

stdlib/public/SDK/Foundation/NSSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension Set {
1818
/// The provided `NSSet` will be copied to ensure that the copy can
1919
/// not be mutated by other code.
2020
public init(_cocoaSet: _NSSet) {
21-
precondition(_isBridgedVerbatimToObjectiveC(Element.self),
21+
assert(_isBridgedVerbatimToObjectiveC(Element.self),
2222
"Set can be backed by NSSet _variantStorage only when the member type can be bridged verbatim to Objective-C")
2323
// FIXME: We would like to call CFSetCreateCopy() to avoid doing an
2424
// objc_msgSend() for instances of CoreFoundation types. We can't do that

stdlib/public/SDK/Foundation/NSStringAPI.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ extension StringProtocol where Index == String.Index {
16371637
public func contains<T : StringProtocol>(_ other: T) -> Bool {
16381638
let r = self.range(of: other) != nil
16391639
if #available(macOS 10.10, iOS 8.0, *) {
1640-
precondition(r == _ns.contains(other._ephemeralString))
1640+
assert(r == _ns.contains(other._ephemeralString))
16411641
}
16421642
return r
16431643
}
@@ -1660,7 +1660,7 @@ extension StringProtocol where Index == String.Index {
16601660
of: other, options: .caseInsensitive, locale: Locale.current
16611661
) != nil
16621662
if #available(macOS 10.10, iOS 8.0, *) {
1663-
precondition(r ==
1663+
assert(r ==
16641664
_ns.localizedCaseInsensitiveContains(other._ephemeralString))
16651665
}
16661666
return r

0 commit comments

Comments
 (0)