[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.
This commit is contained in:
Doug Gregor
2023-11-10 08:20:10 -08:00
parent af79dd815f
commit 304ce052f5

View File

@@ -175,7 +175,7 @@ internal class _AnySequenceBox<Element> {
@inlinable
internal func _map<T>(
_ transform: (Element) throws -> T
) rethrows -> [T] {
) throws -> [T] {
_abstract()
}
@@ -525,13 +525,8 @@ internal final class _SequenceBox<S: Sequence>: _AnySequenceBox<S.Element> {
@inlinable
internal override func _map<T>(
_ transform: (Element) throws -> T
) rethrows -> [T] {
do {
return try _base.map(transform)
} catch {
try _rethrowsViaClosure { throw error }
Builtin.unreachable()
}
) throws -> [T] {
try _base.map(transform)
}
@inlinable
internal override func _filter(
@@ -623,13 +618,8 @@ internal final class _CollectionBox<S: Collection>: _AnyCollectionBox<S.Element>
@inlinable
internal override func _map<T>(
_ transform: (Element) throws -> T
) rethrows -> [T] {
do {
return try _base.map(transform)
} catch {
try _rethrowsViaClosure { throw error }
Builtin.unreachable()
}
) throws -> [T] {
try _base.map(transform)
}
@inlinable
internal override func _filter(
@@ -823,13 +813,8 @@ internal final class _BidirectionalCollectionBox<S: BidirectionalCollection>
@inlinable
internal override func _map<T>(
_ transform: (Element) throws -> T
) rethrows -> [T] {
do {
return try _base.map(transform)
} catch {
try _rethrowsViaClosure { throw error }
Builtin.unreachable()
}
) throws -> [T] {
try _base.map(transform)
}
@inlinable
internal override func _filter(
@@ -1041,13 +1026,8 @@ internal final class _RandomAccessCollectionBox<S: RandomAccessCollection>
@inlinable
internal override func _map<T>(
_ transform: (Element) throws -> T
) rethrows -> [T] {
do {
return try _base.map(transform)
} catch {
try _rethrowsViaClosure { throw error }
Builtin.unreachable()
}
) throws -> [T] {
try _base.map(transform)
}
@inlinable
internal override func _filter(