mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Fixes a correctness issue with unsafe addressors: `unsafeAddress` and `unsafeMutableAddress`. Previously, the resulting `Unsafe[Mutable]Pointer` did not depend on `self`, meaning that the compiler is allowed to destroy `self` before any uses of the pointer. This happens to be valid for `UnsafePointer.pointee` because, in that case, `self` does not have a lifetime anyway; the correctness burden was on the programmer to use `withExtendedLifetime` around all uses of `self`. Now, unsafe addressors can be used for arbitrary `Self` types. This also enables lifetime dependence diagnostics when the addressor points to a `~Escapable` type. Addressors can now be used as an implementation of borrowed properties.
2.0 KiB
2.0 KiB