luaur_analysis/methods/
subtyping_try_semantic_subtyping.rs1use crate::records::scope::Scope;
2use crate::records::subtyping::Subtyping;
3use crate::records::subtyping_environment::SubtypingEnvironment;
4use crate::records::subtyping_result::SubtypingResult;
5use crate::type_aliases::type_id::TypeId;
6
7impl Subtyping {
8 pub fn try_semantic_subtyping(
9 &mut self,
10 env: &mut SubtypingEnvironment,
11 sub_ty: TypeId,
12 super_ty: TypeId,
13 scope: *mut Scope,
14 original: &mut SubtypingResult,
15 ) -> SubtypingResult {
16 let sub_norm = unsafe { (*self.normalizer).normalize(sub_ty) };
17 let super_norm = unsafe { (*self.normalizer).normalize(super_ty) };
18 let mut semantic = self
19 .is_covariant_with_subtyping_environment_shared_ptr_normalized_type_shared_ptr_normalized_type_not_null_scope(
20 env,
21 &sub_norm,
22 &super_norm,
23 scope,
24 );
25
26 if semantic.normalization_too_complex {
27 semantic
28 } else if semantic.is_subtype {
29 semantic.reasoning.clear();
30 semantic
31 } else {
32 original.clone()
33 }
34 }
35}