Skip to main content

luaur_analysis/functions/
is_table_intersection.rs

1use crate::functions::flatten_intersection::flatten_intersection;
2use crate::functions::follow_type::follow_type_id;
3use crate::functions::get_type_alt_j::get;
4use crate::records::intersection_type::IntersectionType;
5use crate::records::table_type::TableType;
6use crate::type_aliases::type_id::TypeId;
7
8pub fn is_table_intersection(ty: TypeId) -> bool {
9    unsafe {
10        if get::<IntersectionType>(follow_type_id(ty)).is_null() {
11            return false;
12        }
13
14        let parts = flatten_intersection(ty);
15        parts.iter().all(|&part| !get::<TableType>(part).is_null())
16    }
17}