mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
3c7cd8fc0c
`emitThrow` previously asserted that the only legal mismatch between the in-flight error type and the throw destination was `any Error`, then existential-erased to `Error`. Anything else Sema accepted — `do throws(any P) where P: Error`, or a class subtype of the destination — crashed the assertion (or, before that was tightened, miscompiled at runtime). Dispatch on the destination type: - existential: erase, looking up conformance to each protocol in the destination's existential layout (so `any P` works, not just `any Error`); - class: emit an `upcast`. Anything else still hits an `unreachable` — Sema rejects those today, so hitting it would indicate a Sema regression rather than a missing SILGen path. Fixes https://github.com/swiftlang/swift/issues/83826.