In backwards compatibility mode, be more permissive of Obj-C null references (#35825)
In backwards compatibility mode, be more permissive of Obj-C null references (#35825)

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
xwu/swift,apple/swift,rudkx/swift,atrick/swift,parkera/swift,xwu/swift,roambotics/swift,glessard/swift,parkera/swift,benlangmuir/swift,apple/swift,parkera/swift,JGiola/swift,tkremenek/swift,atrick/swift,rudkx/swift,parkera/swift,hooman/swift,tkremenek/swift,JGiola/swift,ahoppen/swift,ahoppen/swift,hooman/swift,rudkx/swift,hooman/swift,xwu/swift,parkera/swift,parkera/swift,benlangmuir/swift,glessard/swift,xwu/swift,tkremenek/swift,apple/swift,apple/swift,gregomni/swift,atrick/swift,glessard/swift,parkera/swift,apple/swift,glessard/swift,JGiola/swift,benlangmuir/swift,rudkx/swift,xwu/swift,JGiola/swift,benlangmuir/swift,rudkx/swift,glessard/swift,xwu/swift,roambotics/swift,gregomni/swift,gregomni/swift,tkremenek/swift,tkremenek/swift,apple/swift,gregomni/swift,ahoppen/swift,ahoppen/swift,glessard/swift,rudkx/swift,xwu/swift,hooman/swift,JGiola/swift,benlangmuir/swift,roambotics/swift,atrick/swift,JGiola/swift,hooman/swift,gregomni/swift,tkremenek/swift,roambotics/swift,gregomni/swift,benlangmuir/swift,parkera/swift,tkremenek/swift,ahoppen/swift,hooman/swift,roambotics/swift,atrick/swift,hooman/swift,ahoppen/swift,atrick/swift,roambotics/swift