mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The new cast logic checks and aborts if a non-nullable pointer has a null value at runtime. However, because this was tolerated by the old casting logic, some apps inadvertently rely on being able to cast such null references. This change adds specific checks for null pointers in compatibility mode and handles them similarly to the previous casting logic: * Casting to Obj-C or CF type: casting a null pointer succeeds * Casting to class-constrained existential: casting a null pointer succeeds * Casting to a Swift class type: cast fails without crashing * Bridging from Obj-C class to Swift struct type: cast fails without crashing This also adds a guard to avoid trying to lookup the dynamic type of a null class reference. In non-compatibility mode, all of the above cause an immediate runtime crash. The changes here are only intended to support existing binaries running against new Swift runtimes. Resolves rdar://72323929
88 KiB
88 KiB