luaur_analysis/methods/
mapped_generic_environment_bind_generic.rs1use crate::records::generic_type_pack::GenericTypePack;
2use crate::records::mapped_generic_environment::MappedGenericEnvironment;
3use crate::type_aliases::type_pack_id::TypePackId;
4use luaur_common::macros::luau_assert::LUAU_ASSERT;
5use luaur_common::records::variant::Variant3;
6
7impl MappedGenericEnvironment {
8 pub fn bind_generic(&mut self, generic_tp: TypePackId, bindee_tp: TypePackId) -> bool {
9 if generic_tp == bindee_tp {
11 return true;
12 }
13
14 if unsafe {
15 crate::functions::get_type_pack::get_type_pack_id::<GenericTypePack>(generic_tp)
16 }
17 .is_null()
18 {
19 LUAU_ASSERT!(false);
20 return false;
21 }
22
23 let lookup_result = self.lookup_generic_pack(generic_tp);
24 if let Variant3::V1(unmapped) = lookup_result {
25 *self.frames[unmapped.scope_index]
26 .mappings
27 .get_or_insert(generic_tp) = Some(bindee_tp);
28 true
29 } else {
30 false
31 }
32 }
33}