luaur_analysis/methods/
unifier_2_unify_unifier_2_alt_g.rs1use crate::enums::unify_result::UnifyResult;
2use crate::functions::follow_type::follow_type_id;
3use crate::records::intersection_type::IntersectionType;
4use crate::records::unifier_2::Unifier2;
5use crate::type_aliases::type_id::TypeId;
6
7impl Unifier2 {
8 pub fn unify_intersection_type_type_id(
9 &mut self,
10 sub_intersection: &IntersectionType,
11 super_ty: TypeId,
12 ) -> UnifyResult {
13 let super_ty = unsafe { follow_type_id(super_ty) };
14
15 for &sub_option in sub_intersection.parts.iter() {
16 let followed_sub_option = unsafe { follow_type_id(sub_option) };
17 if super_ty == followed_sub_option {
18 return UnifyResult::Ok;
19 }
20 }
21
22 let mut result = UnifyResult::Ok;
23
24 for sub_part in sub_intersection.parts.iter() {
25 result &= self.unify_type_id_type_id(*sub_part, super_ty);
26 }
27
28 result
29 }
30}