Skip to main content

luaur_analysis/methods/
constraint_solver_try_dispatch_constraint_solver_alt_l.rs

1use crate::functions::follow_type::follow_type_id;
2use crate::records::blocked_type_finder::BlockedTypeFinder;
3use crate::records::constraint::Constraint;
4use crate::records::constraint_solver::ConstraintSolver;
5use crate::records::has_indexer_constraint::HasIndexerConstraint;
6use luaur_common::FFlag;
7
8impl ConstraintSolver {
9    pub fn try_dispatch_has_indexer_constraint_not_null_constraint(
10        &mut self,
11        c: &HasIndexerConstraint,
12        constraint: *const Constraint,
13    ) -> bool {
14        let subject_type = unsafe { follow_type_id(c.subject_type) };
15        let index_type = unsafe { follow_type_id(c.index_type) };
16
17        if self.is_blocked_type_id(subject_type) {
18            return self.block_type_id_not_null_constraint(subject_type, constraint);
19        }
20        if self.is_blocked_type_id(index_type) {
21            return self.block_type_id_not_null_constraint(index_type, constraint);
22        }
23
24        let mut btf = BlockedTypeFinder::blocked_type_finder_blocked_type_finder();
25        btf.visit_type_id(subject_type);
26
27        if let Some(blocked) = btf.blocked {
28            return self.block_type_id_not_null_constraint(blocked, constraint);
29        }
30
31        let mut recursion_depth = 0;
32        let mut seen = luaur_common::records::dense_hash_set::DenseHashSet::new(core::ptr::null());
33
34        let result = self.constraint_solver_try_dispatch_has_indexer(
35            &mut recursion_depth,
36            constraint,
37            subject_type,
38            index_type,
39            c.result_type,
40            &mut seen,
41        );
42
43        if FFlag::LuauConstraintGraph.get() && result {
44            self.unblock_type_id_location(
45                subject_type,
46                luaur_ast::records::location::Location::default(),
47            );
48        }
49
50        result
51    }
52}