Files
swift-mirror/test/SILGen/issue-77295.swift
Hamish Knight c597023d38 [CS] Map caught error type into context
Factor out `ConstraintSystem::getExplicitCaughtErrorType` from 
`getCaughtErrorType`. Then use this for the contextual
type for a `throw` syntactic element.

rdar://139000351
2025-03-24 20:08:43 +00:00

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
}
}
}