Skip to main content

luaur_analysis/methods/
normalizer_union_functions_with_function.rs

1use crate::records::normalized_function_type::NormalizedFunctionType;
2use crate::records::normalizer::Normalizer;
3use crate::records::type_ids::TypeIds;
4use crate::type_aliases::type_id::TypeId;
5
6impl Normalizer {
7    pub fn union_functions_with_function(
8        &mut self,
9        heres: &mut NormalizedFunctionType,
10        there: TypeId,
11    ) {
12        self.consume_fuel();
13
14        if heres.is_never() {
15            let mut tmps = TypeIds::type_ids();
16            tmps.insert_type_id(there);
17            heres.parts = tmps;
18            return;
19        }
20
21        let mut tmps = TypeIds::type_ids();
22        let parts = heres.parts.clone();
23        for here in parts.order {
24            if let Some(fun) = self.union_of_functions(here, there) {
25                tmps.insert_type_id(fun);
26            } else {
27                let builtin_types = unsafe { &*self.builtin_types };
28                tmps.insert_type_id(builtin_types.error_recovery_type(there));
29            }
30        }
31        heres.parts = tmps;
32    }
33}