Skip to content

Commit 5321c34

Browse files
committed
Switch to standard library preconditions
1 parent b60223b commit 5321c34

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

stdlib/public/core/RangeSetStorage.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ struct _RangeSetStorage<T: Comparable> {
3737
}
3838

3939
func unsafeRange(low: Int32, high: Int) -> Range<T> {
40-
unsafeBitCast(Int(low)..<high, to: Range<T>.self)
40+
_precondition(T.self == Int.self)
41+
return unsafeBitCast(Int(low)..<high, to: Range<T>.self)
4142
}
4243
}
4344

@@ -97,7 +98,7 @@ extension _RangeSetStorage: RandomAccessCollection, MutableCollection {
9798
switch _storage {
9899
case .empty: fatalError("Can't access elements of empty storage")
99100
case let .singleRange(high, low):
100-
assert(T.self == Int.self)
101+
_precondition(T.self == Int.self)
101102
return unsafeRange(low: low, high: high)
102103
case let .variadic(ranges):
103104
return ranges[i]
@@ -107,7 +108,7 @@ extension _RangeSetStorage: RandomAccessCollection, MutableCollection {
107108
switch _storage {
108109
case .empty: fatalError("Can't access elements of empty storage")
109110
case .singleRange:
110-
assert(T.self == Int.self)
111+
_precondition(T.self == Int.self)
111112
let intRange = newValue as! Range<Int>
112113
if let lowerBound = Int32(exactly: intRange.lowerBound) {
113114
_storage = .singleRange(high: intRange.upperBound, low: lowerBound)

0 commit comments

Comments
 (0)