swift
9b9dffe6 - [SIL] Don't fold casts from ~Copyable archetypes to Copyable existentials

Commit
4 days ago
[SIL] Don't fold casts from ~Copyable archetypes to Copyable existentials classifyDynamicCastToProtocol treated a cast from an archetype to an existential as always succeeding when the archetype conforms to the existential's protocol. That ignores the existential's own Copyable and Escapable requirements: for `T: P, ~Copyable`, a cast to `any P` succeeds only when the dynamic type of T is Copyable. Concrete source types were already rejected when they lack these requirements, but archetypes were not, so `x is any P` with a non-Copyable dynamic type was folded to `true` at -O. Classify such casts as MaySucceed so that they are decided at runtime.
Author
Committer
Parents
Loading