Skip to main content

luaur_analysis/methods/
constraint_generator_make_union_constraint_generator.rs

1//! @interface-stub
2use crate::functions::follow_type::follow;
3use crate::functions::get_type_alt_j::get_type_id;
4use crate::functions::simplify_union::simplify_union;
5use crate::records::constraint_generator::ConstraintGenerator;
6use crate::records::never_type::NeverType;
7use crate::records::scope::Scope;
8use crate::records::union_type::UnionType;
9use crate::type_aliases::type_id::TypeId;
10use luaur_ast::records::location::Location;
11
12impl ConstraintGenerator {
13    pub fn make_union_scope_ptr_location_type_id_type_id(
14        &mut self,
15        _scope: *mut Scope,
16        _location: Location,
17        lhs: TypeId,
18        rhs: TypeId,
19    ) -> TypeId {
20        unsafe {
21            if !get_type_id::<NeverType>(follow(lhs)).is_null() {
22                return rhs;
23            }
24
25            if !get_type_id::<NeverType>(follow(rhs)).is_null() {
26                return lhs;
27            }
28
29            let result = simplify_union(self.builtin_types, self.arena, lhs, rhs).result;
30
31            if !get_type_id::<UnionType>(follow(result)).is_null() {
32                self.unions_to_simplify.push(result);
33            }
34
35            result
36        }
37    }
38}