mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We have had a heuristic that lets you reflect fields of types, where the field's type is conditionally Copyable, despite the reflection infrastructure always copying a field. That heuristic was added to allow ubiquitous types like Optional in the stdlib to continue to be reflected, even if the Optional at runtime really isn't Copyable. As a consequence, we were also allowing reflection of fields containing user-defined conditionally copyable types, when that's unsafe for no real benefit, yielding runtime crashes! I think in that case it's better to fall-back on the non-crashy case of reflection seeing it as the EmptyTupleType, which isn't inhabited, so it won't try to copy the field and instead basically skip-over it until a future runtime supports the reflection safely. So, this patch limits the dangerous reflection to only stdlib-defined types, until Mirror and friends are updated.
63 KiB
63 KiB