Skip to main content

luaur_analysis/records/
refinement_partition.rs

1use crate::type_aliases::type_id::TypeId;
2use alloc::vec::Vec;
3
4#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5pub struct RefinementPartition {
6    /// Types that we want to intersect against the type of the expression.
7    pub(crate) discriminant_types: Vec<TypeId>,
8    /// Sometimes the type we're discriminating against is implicitly nil.
9    pub(crate) should_append_nil_type: bool,
10}
11
12impl Default for RefinementPartition {
13    fn default() -> Self {
14        Self {
15            discriminant_types: Vec::new(),
16            should_append_nil_type: false,
17        }
18    }
19}
20
21#[allow(non_snake_case)]
22impl RefinementPartition {
23    pub fn discriminantTypes(&self) -> &[TypeId] {
24        &self.discriminant_types
25    }
26
27    pub fn shouldAppendNilType(&self) -> bool {
28        self.should_append_nil_type
29    }
30}