Skip to main content

luaur_analysis/methods/
normalizer_intersect_tyvars_with_ty.rs

1use crate::enums::normalization_result::NormalizationResult;
2use crate::functions::is_shallow_inhabited::is_shallow_inhabited;
3use crate::records::normalizer::Normalizer;
4use crate::type_aliases::normalized_tyvars::NormalizedTyvars;
5use crate::type_aliases::seen_table_prop_pairs::SeenTablePropPairs;
6use crate::type_aliases::type_id::TypeId;
7use luaur_common::records::dense_hash_set::DenseHashSet;
8
9impl Normalizer {
10    pub fn intersect_tyvars_with_ty(
11        &mut self,
12        here: &mut NormalizedTyvars,
13        there: TypeId,
14        seen_table_prop_pairs: &mut SeenTablePropPairs,
15        seen_set_types: &mut DenseHashSet<TypeId>,
16    ) -> NormalizationResult {
17        self.consume_fuel();
18
19        let mut it = here.iter_mut();
20        while let Some((_, inter_box)) = it.next() {
21            let inter = inter_box.as_mut();
22            let res =
23                self.intersect_normal_with_ty(inter, there, seen_table_prop_pairs, seen_set_types);
24            if res != NormalizationResult::True {
25                return res;
26            }
27            if is_shallow_inhabited(inter) {
28                // keep this entry
29            } else {
30                // remove this entry
31                it = here.iter_mut();
32                continue;
33            }
34        }
35        NormalizationResult::True
36    }
37}