TypeResolver

Struct TypeResolver 

Source
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>

Source

pub fn new( interner: &'i ThreadedInterner, source: &'c Source, names: &'c ResolvedNames, codebase: Option<&'c CodebaseReflection>, ) -> Self

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more