Replace `dynamic_cast` with  `std::is_base_of` used in the object_to_luaval