Skip to content

Commit d2aee43

Browse files
committed
Merge pull request #2379 from rudkx/unreachable
2 parents 7d69aee + e03d334 commit d2aee43

35 files changed

+115
-115
lines changed

stdlib/public/core/Algorithm.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ public struct EnumerateSequence<Base : Sequence> {}
128128
extension EnumeratedIterator {
129129
@available(*, unavailable, message: "use the 'enumerated()' method on the sequence")
130130
public init(_ base: Base) {
131-
fatalError("unavailable function can't be called")
131+
Builtin.unreachable()
132132
}
133133
}
134134

135135
extension EnumeratedSequence {
136136
@available(*, unavailable, message: "use the 'enumerated()' method on the sequence")
137137
public init(_ base: Base) {
138-
fatalError("unavailable function can't be called")
138+
Builtin.unreachable()
139139
}
140140
}
141141

stdlib/public/core/Arrays.swift.gyb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,19 +2057,19 @@ extension ContiguousArray {
20572057
extension ${Self} {
20582058
@available(*, unavailable, message: "Please use init(repeating:count:) instead")
20592059
init(count: Int, repeatedValue: Element) {
2060-
fatalError("unavailable function can't be called")
2060+
Builtin.unreachable()
20612061
}
20622062

20632063
@available(*, unavailable, renamed: "remove")
20642064
public mutating func removeAtIndex(_ index: Int) -> Element {
2065-
fatalError("unavailable function can't be called")
2065+
Builtin.unreachable()
20662066
}
20672067

20682068
@available(*, unavailable, renamed: "replaceSubrange")
20692069
public mutating func replaceRange<
20702070
C : Collection where C.Iterator.Element == _Buffer.Element
20712071
>(_ subRange: Range<Int>, with newElements: C) {
2072-
fatalError("unavailable function can't be called")
2072+
Builtin.unreachable()
20732073
}
20742074

20752075
@available(*, unavailable, renamed: "append(contentsOf:)")
@@ -2078,7 +2078,7 @@ extension ${Self} {
20782078
where
20792079
S.Iterator.Element == Element
20802080
>(_ newElements: S) {
2081-
fatalError("unavailable function can't be called")
2081+
Builtin.unreachable()
20822082
}
20832083
}
20842084
%end

stdlib/public/core/BridgeObjectiveC.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,12 @@ extension AutoreleasingUnsafeMutablePointer {
530530

531531
@available(*, unavailable, renamed: "pointee")
532532
public var memory: Pointee {
533-
fatalError("unavailable function can't be called")
533+
Builtin.unreachable()
534534
}
535535

536536
@available(*, unavailable, message: "Removed in Swift 3. Please use nil literal instead.")
537537
public init() {
538-
fatalError("unavailable function can't be called")
538+
Builtin.unreachable()
539539
}
540540
}
541541
#endif

stdlib/public/core/Builtin.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public func unsafeAddress(of object: AnyObject) -> UnsafePointer<Void> {
204204

205205
@available(*, unavailable, renamed: "unsafeAddress(of:)")
206206
public func unsafeAddressOf(_ object: AnyObject) -> UnsafePointer<Void> {
207-
fatalError("unavailable function can't be called")
207+
Builtin.unreachable()
208208
}
209209

210210
/// Converts a reference of type `T` to a reference of type `U` after
@@ -594,5 +594,5 @@ func _isOptional<T>(_ type: T.Type) -> Bool {
594594

595595
@available(*, unavailable, message: "Removed in Swift 3. Please use Optional.unsafelyUnwrapped instead.")
596596
public func unsafeUnwrap<T>(_ nonEmpty: T?) -> T {
597-
fatalError("unavailable function can't be called")
597+
Builtin.unreachable()
598598
}

stdlib/public/core/CString.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ extension String {
9494
@available(*, unavailable, message: "Please use String.init?(validatingUTF8:) instead. Note that it no longer accepts NULL as a valid input. Also consider using String(cString:), that will attempt to repair ill-formed code units.")
9595
@warn_unused_result
9696
public static func fromCString(_ cs: UnsafePointer<CChar>) -> String? {
97-
fatalError("unavailable function can't be called")
97+
Builtin.unreachable()
9898
}
9999

100100
@available(*, unavailable, message: "Please use String.init(cString:) instead. Note that it no longer accepts NULL as a valid input. See also String.decodeCString if you need more control.")
101101
@warn_unused_result
102102
public static func fromCStringRepairingIllFormedUTF8(
103103
_ cs: UnsafePointer<CChar>
104104
) -> (String?, hadError: Bool) {
105-
fatalError("unavailable function can't be called")
105+
Builtin.unreachable()
106106
}
107107
}

stdlib/public/core/Collection.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,12 +1468,12 @@ extension Collection {
14681468

14691469
@available(*, unavailable, renamed: "makeIterator")
14701470
public func generate() -> Iterator {
1471-
fatalError("unavailable function can't be called")
1471+
Builtin.unreachable()
14721472
}
14731473

14741474
@available(*, unavailable, message: "Removed in Swift 3. Please use underestimatedCount property.")
14751475
public func underestimateCount() -> Int {
1476-
fatalError("unavailable function can't be called")
1476+
Builtin.unreachable()
14771477
}
14781478

14791479
@available(*, unavailable, message: "Please use split(maxSplits:omittingEmptySubsequences:isSeparator:) instead")
@@ -1482,7 +1482,7 @@ extension Collection {
14821482
allowEmptySlices: Bool = false,
14831483
isSeparator: @noescape (Iterator.Element) throws -> Bool
14841484
) rethrows -> [SubSequence] {
1485-
fatalError("unavailable function can't be called")
1485+
Builtin.unreachable()
14861486
}
14871487
}
14881488

@@ -1493,7 +1493,7 @@ extension Collection where Iterator.Element : Equatable {
14931493
maxSplit: Int = Int.max,
14941494
allowEmptySlices: Bool = false
14951495
) -> [SubSequence] {
1496-
fatalError("unavailable function can't be called")
1496+
Builtin.unreachable()
14971497
}
14981498
}
14991499

stdlib/public/core/CollectionAlgorithms.swift.gyb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ extension MutableCollection where Self : RandomAccessCollection {
642642
_ range: Range<Index>,
643643
isOrderedBefore: (${IElement}, ${IElement}) -> Bool
644644
) -> Index {
645-
fatalError("unavailable function can't be called")
645+
Builtin.unreachable()
646646
}
647647
}
648648

@@ -651,7 +651,7 @@ extension MutableCollection
651651

652652
@available(*, unavailable, message: "slice the collection using the range, and call partition()")
653653
public mutating func partition(_ range: Range<Index>) -> Index {
654-
fatalError("unavailable function can't be called")
654+
Builtin.unreachable()
655655
}
656656
}
657657

@@ -662,7 +662,7 @@ extension MutableCollection
662662

663663
@available(*, unavailable, renamed: "sort")
664664
public mutating func sortInPlace() {
665-
fatalError("unavailable function can't be called")
665+
Builtin.unreachable()
666666
}
667667
}
668668

@@ -671,15 +671,15 @@ extension MutableCollection where Self : RandomAccessCollection {
671671
public mutating func sortInPlace(
672672
_ isOrderedBefore: @noescape (Iterator.Element, Iterator.Element) -> Bool
673673
) {
674-
fatalError("unavailable function can't be called")
674+
Builtin.unreachable()
675675
}
676676
}
677677

678678
extension Collection where ${IElement} : Equatable {
679679
@available(*, unavailable, renamed: "index(of:)")
680680
@warn_unused_result
681681
public func indexOf(_ element: ${IElement}) -> Index? {
682-
fatalError("unavailable function can't be called")
682+
Builtin.unreachable()
683683
}
684684
}
685685

@@ -689,6 +689,6 @@ extension Collection {
689689
public func indexOf(
690690
_ predicate: @noescape (${IElement}) throws -> Bool
691691
) rethrows -> Index? {
692-
fatalError("unavailable function can't be called")
692+
Builtin.unreachable()
693693
}
694694
}

stdlib/public/core/CollectionOfOne.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ public struct GeneratorOfOne<Element> {}
106106
extension IteratorOverOne {
107107
@available(*, unavailable, renamed: "makeIterator")
108108
public func generate() -> IteratorOverOne<Element> {
109-
fatalError("unavailable function can't be called")
109+
Builtin.unreachable()
110110
}
111111
}

stdlib/public/core/EmptyCollection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@ public struct EmptyGenerator<Element> {}
162162
extension EmptyIterator {
163163
@available(*, unavailable, renamed: "makeIterator")
164164
public func generate() -> EmptyIterator<Element> {
165-
fatalError("unavailable function can't be called")
165+
Builtin.unreachable()
166166
}
167167
}

stdlib/public/core/ExistentialCollection.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ public struct AnyGenerator<Element> {}
11061106
extension AnyIterator {
11071107
@available(*, unavailable, renamed: "makeIterator")
11081108
public func generate() -> AnyIterator<Element> {
1109-
fatalError("unavailable function can't be called")
1109+
Builtin.unreachable()
11101110
}
11111111
}
11121112

@@ -1115,7 +1115,7 @@ extension Any${Kind} {
11151115

11161116
@available(*, unavailable, message: "Please use underestimatedCount property instead.")
11171117
public var underestimateCount: Int {
1118-
fatalError("unavailable function can't be called")
1118+
Builtin.unreachable()
11191119
}
11201120
}
11211121
%end
@@ -1126,6 +1126,6 @@ public typealias AnyCollectionType = AnyCollectionProtocol
11261126
extension AnyCollectionProtocol {
11271127
@available(*, unavailable, renamed: "makeIterator")
11281128
public func generate() -> AnyIterator<Iterator.Element> {
1129-
fatalError("unavailable function can't be called")
1129+
Builtin.unreachable()
11301130
}
11311131
}

0 commit comments

Comments
 (0)