Skip to content

Commit bb63c8e

Browse files
committed
[Existential collections] Switch internal _map rethrows methods to throws
These class methods are internal, but because they are overridden and are part of a `@usableFromInline`, `@_fixed_layout` class, we they can't be moved over to typed throws without breaking ABI. However, they are only ever called from typed-throws functions, which already need a do...catch dance to downcast the error itself. Make them `throws` instead, which is ABI-compatible, but eliminates the need for do...catch hackery in the function itself.
1 parent 41e7b7c commit bb63c8e

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed

stdlib/public/core/ExistentialCollection.swift

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ internal class _AnySequenceBox<Element> {
175175
@inlinable
176176
internal func _map<T>(
177177
_ transform: (Element) throws -> T
178-
) rethrows -> [T] {
178+
) throws -> [T] {
179179
_abstract()
180180
}
181181

@@ -525,13 +525,8 @@ internal final class _SequenceBox<S: Sequence>: _AnySequenceBox<S.Element> {
525525
@inlinable
526526
internal override func _map<T>(
527527
_ transform: (Element) throws -> T
528-
) rethrows -> [T] {
529-
do {
530-
return try _base.map(transform)
531-
} catch {
532-
try _rethrowsViaClosure { throw error }
533-
Builtin.unreachable()
534-
}
528+
) throws -> [T] {
529+
try _base.map(transform)
535530
}
536531
@inlinable
537532
internal override func _filter(
@@ -623,13 +618,8 @@ internal final class _CollectionBox<S: Collection>: _AnyCollectionBox<S.Element>
623618
@inlinable
624619
internal override func _map<T>(
625620
_ transform: (Element) throws -> T
626-
) rethrows -> [T] {
627-
do {
628-
return try _base.map(transform)
629-
} catch {
630-
try _rethrowsViaClosure { throw error }
631-
Builtin.unreachable()
632-
}
621+
) throws -> [T] {
622+
try _base.map(transform)
633623
}
634624
@inlinable
635625
internal override func _filter(
@@ -823,13 +813,8 @@ internal final class _BidirectionalCollectionBox<S: BidirectionalCollection>
823813
@inlinable
824814
internal override func _map<T>(
825815
_ transform: (Element) throws -> T
826-
) rethrows -> [T] {
827-
do {
828-
return try _base.map(transform)
829-
} catch {
830-
try _rethrowsViaClosure { throw error }
831-
Builtin.unreachable()
832-
}
816+
) throws -> [T] {
817+
try _base.map(transform)
833818
}
834819
@inlinable
835820
internal override func _filter(
@@ -1041,13 +1026,8 @@ internal final class _RandomAccessCollectionBox<S: RandomAccessCollection>
10411026
@inlinable
10421027
internal override func _map<T>(
10431028
_ transform: (Element) throws -> T
1044-
) rethrows -> [T] {
1045-
do {
1046-
return try _base.map(transform)
1047-
} catch {
1048-
try _rethrowsViaClosure { throw error }
1049-
Builtin.unreachable()
1050-
}
1029+
) throws -> [T] {
1030+
try _base.map(transform)
10511031
}
10521032
@inlinable
10531033
internal override func _filter(

0 commit comments

Comments
 (0)