Files
react-native/packages/react-native/ReactCommon/react/renderer/observers
Nick Gerleman 1170a68755 Delete traitCast and identifier traits (#42748)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42748

React Native has globally enabled RTTI within `rn_xplat_cxx_library`, ahead of RTTI being forced on (regardless of flag) in Android apps (it was previously enabled everywhere but Android, which has caused us no small share of headaches, with public JSI APIs designed around clients using RTTI).

This diff:
1. Mechanically replaces usages of `traitCast` with equivalent calls to `dynamic_cast` or `dynamic_pointer_cast`
    1. These have similar semantics as current iteration of `traitCast`, where we return `nullptr` for pointer form, or throw on invalid cast for reference form.
2. Removes `IdentifierTrait` as a requirement to cast to a ShadowNode
3. Removes the ShadowNode traits used solely as cast identities

This enables consistent usage of `dynamic_cast` (including for user defined ShadowNodes), and also exposes some places where `traitCast` allowed implicit const conversion.

The OSS builds should already have RTTI on, and will be able to use `dynamic_cast` on RN provided types (`traitCast` is not extendable).

Changelog:
[General][Breaking] - Delete traitCast and identifier traits

Reviewed By: sammy-SC

Differential Revision: D53215009

fbshipit-source-id: d20cbf66b725f5565fa5d03332010d87f2b08b61
2024-02-01 00:33:54 -08:00
..