luaur_analysis/methods/
union_builder_build.rs1use crate::records::type_ids::TypeIds;
2use crate::records::union_builder::UnionBuilder;
3use crate::records::union_type::UnionType;
4use crate::type_aliases::type_id::TypeId;
5
6impl UnionBuilder {
7 pub fn build(&mut self) -> TypeId {
8 if self.is_top {
9 return unsafe { (*self.builtin_types).unknownType };
10 }
11
12 if self.options.size() == 0 {
13 return unsafe { (*self.builtin_types).neverType };
14 }
15
16 if self.options.size() == 1 {
17 return self.options.front();
18 }
19
20 let options_vec = self.options.take();
21 let union_type = UnionType {
22 options: options_vec,
23 };
24 unsafe { (*self.arena).add_type(union_type) }
25 }
26}