Skip to main content

luaur_analysis/methods/
subtyping_maybe_update_bounds.rs

1use crate::records::subtyping::Subtyping;
2use crate::records::type_ids::TypeIds;
3use crate::type_aliases::type_id::TypeId;
4
5impl Subtyping {
6    pub fn maybe_update_bounds(
7        &mut self,
8        here: TypeId,
9        there: TypeId,
10        bounds_to_update: &mut TypeIds,
11        first_bounds_to_check: &TypeIds,
12        second_bounds_to_check: &TypeIds,
13    ) {
14        let mut bounds_changed = false;
15
16        if !first_bounds_to_check.empty() {
17            for t in first_bounds_to_check.order.iter() {
18                let t = *t;
19                if t != here {
20                    bounds_to_update.insert_type_id(t);
21                    bounds_changed = true;
22                }
23            }
24        }
25
26        if !bounds_changed && !second_bounds_to_check.empty() {
27            for t in second_bounds_to_check.order.iter() {
28                let t = *t;
29                if t != here {
30                    bounds_to_update.insert_type_id(t);
31                    bounds_changed = true;
32                }
33            }
34        }
35
36        if !bounds_changed && here != there {
37            bounds_to_update.insert_type_id(there);
38        }
39    }
40}