Skip to main content

luaur_analysis/methods/
unifier_2_unify_unifier_2_alt_e.rs

1use crate::enums::unify_result::UnifyResult;
2use crate::functions::are_compatible::are_compatible;
3use crate::records::unifier_2::Unifier2;
4use crate::records::union_type::UnionType;
5use crate::type_aliases::type_id::TypeId;
6
7impl Unifier2 {
8    pub fn unify_union_type_type_id(
9        &mut self,
10        sub_union: &UnionType,
11        super_ty: TypeId,
12    ) -> UnifyResult {
13        let mut result = UnifyResult::Ok;
14
15        for sub_option in sub_union.options.iter() {
16            if unsafe { are_compatible(*sub_option, super_ty) } {
17                result &= self.unify_type_id_type_id(*sub_option, super_ty);
18            }
19        }
20
21        result
22    }
23}