Files
swift-mirror/lib/SILGen
Ben Cohen 3c7cd8fc0c SILGen: handle non-Error destinations in emitThrow (#88948)
`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.
2026-05-19 11:37:08 -07:00
..
2025-11-19 17:32:20 -08:00