luaur_analysis/methods/
union_builder_add.rs1use crate::functions::follow_type::follow_type_id;
2use crate::functions::get_type_alt_j::get_type_id;
3use crate::records::never_type::NeverType;
4use crate::records::union_builder::UnionBuilder;
5use crate::records::union_type::UnionType;
6use crate::records::unknown_type::UnknownType;
7use crate::type_aliases::type_id::TypeId;
8
9impl UnionBuilder {
10 pub fn add(&mut self, ty: TypeId) {
11 let ty = unsafe { follow_type_id(ty) };
12
13 if unsafe { !get_type_id::<NeverType>(ty).is_null() } || self.is_top {
14 return;
15 }
16
17 if unsafe { !get_type_id::<UnknownType>(ty).is_null() } {
18 self.is_top = true;
19 return;
20 }
21
22 if let Some(utv) = unsafe { get_type_id::<UnionType>(ty).as_ref() } {
23 for &option in utv.options.iter() {
24 self.options.insert_type_id(option);
25 }
26 } else {
27 self.options.insert_type_id(ty);
28 }
29 }
30}