pub struct TypeResolver<'i, 'c> { /* private fields */ }Expand description
A basic type resolver designed to initialize types at the beginning of type checking. This resolver is intentionally simple and acts as a “bootstrap” to get type information that can later be narrowed down for more precise type inference.
While this type resolver is limited in detail, it provides enough information for initial analysis and bootstrapping. However, it requires a subsequent pass to refine types.
§Capabilities
This resolver can completely evaluate constant expressions in most cases and produce a type
with a known value, such as Value::Float(16.5) for expressions like ((12 / 2) + 5) * 1.5.
§Improved Type Resolution with Codebase Context
If a codebase is available, this resolver can leverage it to retrieve types of functions, methods, and constants, making it slightly more powerful in providing initial type information.
Implementations§
Source§impl<'i, 'c> TypeResolver<'i, 'c>
impl<'i, 'c> TypeResolver<'i, 'c>
pub fn new( interner: &'i ThreadedInterner, source: &'c Source, names: &'c ResolvedNames, codebase: Option<&'c CodebaseReflection>, ) -> Self
pub fn resolve(&self, expression: &Expression) -> TypeKind
Auto Trait Implementations§
impl<'i, 'c> Freeze for TypeResolver<'i, 'c>
impl<'i, 'c> !RefUnwindSafe for TypeResolver<'i, 'c>
impl<'i, 'c> Send for TypeResolver<'i, 'c>
impl<'i, 'c> Sync for TypeResolver<'i, 'c>
impl<'i, 'c> Unpin for TypeResolver<'i, 'c>
impl<'i, 'c> !UnwindSafe for TypeResolver<'i, 'c>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more