mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Factor out `ConstraintSystem::getExplicitCaughtErrorType` from `getCaughtErrorType`. Then use this for the contextual type for a `throw` syntactic element. rdar://139000351
14 lines
335 B
Swift
14 lines
335 B
Swift
// RUN: %target-swift-emit-silgen %s -verify
|
|
|
|
// https://github.com/swiftlang/swift/issues/77295 - Make sure this compiles.
|
|
extension Optional {
|
|
func foo<E: Error>(orThrow error: @autoclosure () -> E) throws(E) -> Wrapped {
|
|
switch self {
|
|
case .none:
|
|
throw error()
|
|
case .some(let wrapped):
|
|
wrapped
|
|
}
|
|
}
|
|
}
|