Skip to main content

luaur_analysis/methods/
intersection_builder_build.rs

1use crate::records::intersection_builder::IntersectionBuilder;
2use crate::records::intersection_type::IntersectionType;
3use crate::records::type_ids::TypeIds;
4use crate::type_aliases::type_id::TypeId;
5
6impl IntersectionBuilder {
7    pub fn build(&mut self) -> TypeId {
8        if self.is_bottom {
9            return unsafe { (*self.builtin_types).neverType };
10        }
11
12        if self.parts.size() == 0 {
13            return unsafe { (*self.builtin_types).unknownType };
14        }
15
16        if self.parts.size() == 1 {
17            return self.parts.front();
18        }
19
20        unsafe {
21            (*self.arena).add_type(IntersectionType {
22                parts: self.parts.take(),
23            })
24        }
25    }
26}