luaur_analysis/methods/
constraint_solver_try_dispatch_constraint_solver_alt_f.rs1use crate::functions::follow_type::follow_type_id;
2use crate::records::constraint::Constraint;
3use crate::records::constraint_solver::ConstraintSolver;
4use crate::records::infinite_type_finder::InfiniteTypeFinder;
5use crate::records::intersection_type::IntersectionType;
6use crate::records::iterative_type_visitor::IterativeTypeVisitorTrait;
7use crate::records::metatable_type::MetatableType;
8use crate::records::name_constraint::NameConstraint;
9use crate::records::table_type::TableType;
10use crate::records::union_type::UnionType;
11use crate::type_aliases::type_id::TypeId;
12
13impl ConstraintSolver {
14 pub fn try_dispatch_name_constraint_not_null_constraint(
15 &mut self,
16 c: &NameConstraint,
17 constraint: *const Constraint,
18 ) -> bool {
19 if self.is_blocked_type_id(c.named_type) {
20 return self.block_type_id_not_null_constraint(c.named_type, constraint);
21 }
22
23 let target = unsafe { follow_type_id(c.named_type) };
24
25 unsafe {
26 if (*target).persistent || (*target).owning_arena != self.arena {
27 return true;
28 }
29 }
30
31 if let Some(tf) = unsafe {
32 (*(*constraint).scope)
33 .lookup_type(&crate::type_aliases::name_type::Name::from(c.name.as_str()))
34 } {
35 let signature = crate::records::instantiation_signature::InstantiationSignature {
36 fn_sig: tf,
37 arguments: c.type_parameters.clone(),
38 pack_arguments: c.type_pack_parameters.clone(),
39 };
40
41 let mut itf = InfiniteTypeFinder::infinite_type_finder_infinite_type_finder(
42 self,
43 &signature,
44 unsafe { core::ptr::NonNull::new_unchecked((*constraint).scope) },
45 );
46 itf.run_type_id(target);
47
48 if itf.found_infinite_type {
49 unsafe {
50 (*(*constraint).scope)
51 .invalid_type_aliases
52 .try_insert(c.name.clone(), (*constraint).location)
53 };
54 self.bind_not_null_constraint_type_id_type_id(constraint, target, unsafe {
55 (*self.builtin_types).errorType
56 });
57 return true;
58 }
59 }
60
61 let ttv =
62 unsafe { crate::functions::get_mutable_type::get_mutable_type_id::<TableType>(target) };
63 if !ttv.is_null() {
64 unsafe {
65 if c.synthetic && (*ttv).name.is_none() {
66 (*ttv).synthetic_name = Some(c.name.clone());
67 } else {
68 (*ttv).name = Some(c.name.clone());
69 (*ttv).instantiated_type_params = c.type_parameters.clone();
70 (*ttv).instantiated_type_pack_params = c.type_pack_parameters.clone();
71 }
72 }
73 } else {
74 let mtv = unsafe {
75 crate::functions::get_mutable_type::get_mutable_type_id::<MetatableType>(target)
76 };
77 if !mtv.is_null() {
78 unsafe { (*mtv).syntheticName = Some(c.name.clone()) };
79 }
80 }
81
82 true
83 }
84}