Skip to main content

luaur_analysis/records/
magic_select.rs

1use crate::records::magic_function::MagicFunction;
2use crate::records::magic_function_call_context::MagicFunctionCallContext;
3use crate::records::scope::Scope;
4use crate::records::type_checker::TypeChecker;
5use crate::records::with_predicate::WithPredicate;
6use crate::type_aliases::type_pack_id::TypePackId;
7
8#[derive(Debug, Clone)]
9pub struct MagicSelect {
10    pub(crate) base: MagicFunction,
11    pub(crate) handle_old_solver: fn(
12        &mut TypeChecker,
13        &std::sync::Arc<Scope>,
14        &luaur_ast::records::ast_expr_call::AstExprCall,
15        WithPredicate<TypePackId>,
16    ) -> Option<WithPredicate<TypePackId>>,
17    pub(crate) infer: fn(&MagicFunctionCallContext) -> bool,
18}
19
20impl MagicSelect {
21    pub fn handle_old_solver(
22        &self,
23        context: &mut TypeChecker,
24        scope: &std::sync::Arc<Scope>,
25        call_site: &luaur_ast::records::ast_expr_call::AstExprCall,
26        old_result: WithPredicate<TypePackId>,
27    ) -> Option<WithPredicate<TypePackId>> {
28        (self.handle_old_solver)(context, scope, call_site, old_result)
29    }
30
31    pub fn infer(&self, ctx: &MagicFunctionCallContext) -> bool {
32        (self.infer)(ctx)
33    }
34}