luaur_analysis/methods/
constraint_solver_try_dispatch_constraint_solver_alt_k.rs1use crate::enums::table_state::TableState;
2use crate::functions::can_mutate_constraint_solver::can_mutate;
3use crate::functions::follow_type::follow_type_id;
4use crate::functions::get_table_type::get_table_type;
5use crate::functions::get_type_alt_j::get_type_id;
6use crate::records::blocked_type::BlockedType;
7use crate::records::constraint::Constraint;
8use crate::records::constraint_solver::ConstraintSolver;
9use crate::records::has_prop_constraint::HasPropConstraint;
10use luaur_common::macros::luau_assert::LUAU_ASSERT;
11
12impl ConstraintSolver {
13 pub fn try_dispatch_has_prop_constraint_not_null_constraint(
14 &mut self,
15 c: &HasPropConstraint,
16 constraint: *const Constraint,
17 ) -> bool {
18 let subject_type = unsafe { follow_type_id(c.subject_type) };
19 let result_type = unsafe { follow_type_id(c.result_type) };
20
21 LUAU_ASSERT!(!unsafe { get_type_id::<BlockedType>(result_type) }.is_null());
22 LUAU_ASSERT!(can_mutate(result_type, constraint));
23
24 if self.is_blocked_type_id(subject_type) {
25 return self.block_type_id_not_null_constraint(subject_type, constraint);
26 }
27
28 if let Some(subject_table) = get_table_type(subject_type) {
29 if subject_table.state == TableState::Unsealed
30 && subject_table.remaining_props > 0
31 && !subject_table.props.contains_key(&c.prop)
32 {
33 return self.block_type_id_not_null_constraint(subject_type, constraint);
34 }
35 }
36
37 let lookup = self
38 .lookup_table_prop_not_null_constraint_type_id_string_value_context_bool_bool(
39 constraint,
40 subject_type,
41 &c.prop,
42 c.context,
43 c.in_conditional,
44 c.suppress_simplification,
45 );
46 if !lookup.blocked_types.is_empty() {
47 for blocked in lookup.blocked_types {
48 self.block_type_id_not_null_constraint(blocked, constraint);
49 }
50 return false;
51 }
52
53 self.bind_not_null_constraint_type_id_type_id(
54 constraint,
55 result_type,
56 lookup
57 .prop_type
58 .unwrap_or(unsafe { (*self.builtin_types).anyType }),
59 );
60 true
61 }
62}