Skip to main content

luaur_analysis/methods/
replace_generics_ignore_children.rs

1use crate::functions::get_type_alt_j::get_type_id;
2use crate::functions::get_type_utils::get_optional_ty;
3use crate::records::extern_type::ExternType;
4use crate::records::function_type::FunctionType;
5use crate::records::replace_generics::ReplaceGenerics;
6use crate::type_aliases::type_id::TypeId;
7
8impl ReplaceGenerics {
9    pub fn ignore_children(&self, ty: TypeId) -> bool {
10        let ftv = unsafe { get_type_id::<FunctionType>(ty) };
11        if !ftv.is_null() {
12            let ftv_ref = unsafe { &*ftv };
13            if ftv_ref.has_no_free_or_generic_types {
14                return true;
15            }
16
17            return (!self.generics.is_empty() || !self.generic_packs.is_empty())
18                && (ftv_ref.generics == self.generics)
19                && (ftv_ref.generic_packs == self.generic_packs);
20        }
21
22        let et = unsafe { get_optional_ty::<ExternType, TypeId>(Some(ty)) };
23        if !et.is_null() {
24            return true;
25        }
26
27        false
28    }
29}