mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user