luaur_analysis/functions/
maybe_generic.rs1use crate::functions::follow_type::follow_type_id;
2use crate::functions::get_type_alt_j::get_type_id;
3use crate::functions::is_generic::is_generic;
4use crate::records::free_type::FreeType;
5use crate::records::intersection_type::IntersectionType;
6use crate::records::table_type::TableType;
7use crate::type_aliases::type_id::TypeId;
8use luaur_common::macros::luau_assert::LUAU_ASSERT;
9use luaur_common::FFlag;
10
11pub fn maybe_generic(ty: TypeId) -> bool {
12 LUAU_ASSERT!(!FFlag::LuauInstantiateInSubtyping.get());
13
14 let ty = unsafe { follow_type_id(ty) };
15
16 if unsafe { !get_type_id::<FreeType>(ty).is_null() } {
17 return true;
18 }
19
20 if unsafe { !get_type_id::<TableType>(ty).is_null() } {
21 return true;
23 }
24
25 if let Some(itv) = unsafe { get_type_id::<IntersectionType>(ty).as_ref() } {
26 return itv.parts.iter().any(|&part| maybe_generic(part));
27 }
28
29 is_generic(ty)
30}