Skip to main content

luaur_analysis/functions/
is_overloaded_function.rs

1//! Node: `cxx:Function:Luau.Analysis:Analysis/src/Type.cpp:271:is_overloaded_function`
2//! Source: `Analysis/src/Type.cpp:271-283` (hand-ported)
3
4use crate::functions::flatten_intersection::flatten_intersection;
5use crate::functions::follow_type::follow;
6use crate::functions::get_type_alt_j::get;
7use crate::records::function_type::FunctionType;
8use crate::records::intersection_type::IntersectionType;
9use crate::type_aliases::type_id::TypeId;
10
11pub fn is_overloaded_function(ty: TypeId) -> bool {
12    unsafe {
13        if get::<IntersectionType>(follow(ty)).is_null() {
14            return false;
15        }
16
17        let parts = flatten_intersection(ty);
18        parts
19            .iter()
20            .all(|&part| !get::<FunctionType>(part).is_null())
21    }
22}