Skip to content

Commit 153c001

Browse files
committed
[stdlib] Undo typed throws on withExtendedLifetime
swiftlang#73045 has uncovered a compiler crash with existing code of this form: try withExtendedLifetime(statement) { // 💥silgen crash do { try dbPool.close() XCTFail("Expected Error") } catch DatabaseError.SQLITE_BUSY { } } This patterns can happen with any of the newly typed throwing entry points, but the source compat suite only seems to have caught this with `withExtendedLifetime`; let’s see if we can get away with only rolling back this one.
1 parent a681a3d commit 153c001

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

stdlib/public/core/LifetimeManager.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
/// return value for the `withExtendedLifetime(_:_:)` method.
2121
/// - Returns: The return value, if any, of the `body` closure parameter.
2222
@_alwaysEmitIntoClient
23-
public func withExtendedLifetime<T: ~Copyable, E: Error, Result: ~Copyable>(
23+
public func withExtendedLifetime<T: ~Copyable, Result: ~Copyable>(
2424
_ x: borrowing T,
25-
_ body: () throws(E) -> Result
26-
) throws(E) -> Result {
25+
_ body: () throws -> Result // FIXME: Typed throws rdar://126576356
26+
) rethrows -> Result {
2727
defer { _fixLifetime(x) }
2828
return try body()
2929
}
@@ -32,7 +32,7 @@ public func withExtendedLifetime<T: ~Copyable, E: Error, Result: ~Copyable>(
3232
@usableFromInline
3333
internal func withExtendedLifetime<T, Result>(
3434
_ x: T,
35-
_ body: () throws -> Result
35+
_ body: () throws -> Result // FIXME: Typed throws rdar://126576356
3636
) rethrows -> Result {
3737
defer { _fixLifetime(x) }
3838
return try body()
@@ -48,17 +48,17 @@ internal func withExtendedLifetime<T, Result>(
4848
/// return value for the `withExtendedLifetime(_:_:)` method.
4949
/// - Returns: The return value, if any, of the `body` closure parameter.
5050
@_alwaysEmitIntoClient
51-
public func withExtendedLifetime<T, E: Error, Result: ~Copyable>(
52-
_ x: T, _ body: (T) throws(E) -> Result
53-
) throws(E) -> Result {
51+
public func withExtendedLifetime<T, Result: ~Copyable>(
52+
_ x: T, _ body: (T) throws -> Result // FIXME: Typed throws rdar://126576356
53+
) rethrows -> Result {
5454
defer { _fixLifetime(x) }
5555
return try body(x)
5656
}
5757

5858
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
5959
@usableFromInline
6060
internal func withExtendedLifetime<T, Result>(
61-
_ x: T, _ body: (T) throws -> Result
61+
_ x: T, _ body: (T) throws -> Result // FIXME: Typed throws rdar://126576356
6262
) rethrows -> Result {
6363
defer { _fixLifetime(x) }
6464
return try body(x)

0 commit comments

Comments
 (0)