pub struct TypeCoercion<'a> {
context: &'a CompilationContext,
}
Expand description
Handles all type coercion rules and operations
This module is responsible for determining when and how types can be automatically converted or coerced, particularly for unspecified literal types.
Fields§
§context: &'a CompilationContext
Implementations§
Source§impl<'a> TypeCoercion<'a>
impl<'a> TypeCoercion<'a>
Sourcepub fn new(context: &'a CompilationContext) -> Self
pub fn new(context: &'a CompilationContext) -> Self
Creates a new type coercion handler
§Arguments
context
- The compilation context for type information
Sourcepub fn can_coerce(&self, source_type: &TypeId, target_type: &TypeId) -> bool
pub fn can_coerce(&self, source_type: &TypeId, target_type: &TypeId) -> bool
Sourcepub fn check_mixed_arithmetic_operation(
&self,
left_type: &TypeId,
right_type: &TypeId,
bin_expr: &BinaryExpr,
) -> SemanticResult
pub fn check_mixed_arithmetic_operation( &self, left_type: &TypeId, right_type: &TypeId, bin_expr: &BinaryExpr, ) -> SemanticResult
Checks for mixed-type arithmetic operations with coercion
Handles cases where unspecified literals can be coerced to match the other operand’s type in arithmetic operations.
§Arguments
left_type
- Type of the left operandright_type
- Type of the right operandbin_expr
- The binary expression for context
§Returns
Result with the resulting type or an error
Auto Trait Implementations§
impl<'a> Freeze for TypeCoercion<'a>
impl<'a> RefUnwindSafe for TypeCoercion<'a>
impl<'a> Send for TypeCoercion<'a>
impl<'a> Sync for TypeCoercion<'a>
impl<'a> Unpin for TypeCoercion<'a>
impl<'a> UnwindSafe for TypeCoercion<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more