use crate::enums::subtyping_suppression_policy::SubtypingSuppressionPolicy;
use crate::functions::merge_reasonings::merge_reasonings;
use crate::records::subtyping_result::SubtypingResult;
impl SubtypingResult {
pub fn and_also(
&mut self,
mut other: SubtypingResult,
policy: SubtypingSuppressionPolicy,
) -> &mut Self {
if !other.is_subtype {
if self.is_subtype {
core::mem::swap(&mut self.reasoning, &mut other.reasoning);
} else {
self.reasoning = merge_reasonings(&self.reasoning, &other.reasoning);
}
}
self.is_subtype &= other.is_subtype;
if policy == SubtypingSuppressionPolicy::All {
self.is_error_suppressing &= other.is_error_suppressing;
} else {
self.is_error_suppressing |= other.is_error_suppressing;
}
self.normalization_too_complex |= other.normalization_too_complex;
self.is_cacheable &= other.is_cacheable;
self.errors.extend(other.errors.into_iter());
self.generic_bounds_mismatches
.extend(other.generic_bounds_mismatches.into_iter());
self.assumed_constraints
.extend(other.assumed_constraints.into_iter());
self
}
}