pub struct ApplicationEvaluator<'a, R: TypeResolver> { /* private fields */ }Expand description
Evaluator for generic type applications.
This evaluator takes a type application like Box<string> and:
- Looks up the definition of
Box(via the resolver) - Gets its type parameters
- Substitutes the type arguments
- Returns the resulting type
§Type Resolver
The evaluator uses a TypeResolver to handle symbol resolution.
This abstraction allows the solver to remain independent of the binder/checker:
resolve_ref(symbol)- get the body type of a type alias/interfaceget_type_params(symbol)- get the type parameters for a symbol
Implementations§
Source§impl<'a, R: TypeResolver> ApplicationEvaluator<'a, R>
impl<'a, R: TypeResolver> ApplicationEvaluator<'a, R>
Sourcepub fn new(interner: &'a dyn TypeDatabase, resolver: &'a R) -> Self
pub fn new(interner: &'a dyn TypeDatabase, resolver: &'a R) -> Self
Create a new application evaluator.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the evaluation cache. Call this when contextual type changes to ensure fresh evaluation.
Sourcepub fn evaluate(&self, type_id: TypeId) -> ApplicationResult
pub fn evaluate(&self, type_id: TypeId) -> ApplicationResult
Evaluate an Application type by resolving the base symbol and instantiating.
This handles types like Store<ExtractState<R>> by:
- Resolving the base type reference to get its body
- Getting the type parameters
- Instantiating the body with the provided type arguments
- Recursively evaluating the result
§Returns
ApplicationResult::Resolved(type_id)- successfully evaluatedApplicationResult::NotApplication(type_id)- input was not an application typeApplicationResult::DepthExceeded(type_id)- recursion limit reachedApplicationResult::ResolutionFailed(type_id)- symbol resolution failed
Sourcepub fn evaluate_or_original(&self, type_id: TypeId) -> TypeId
pub fn evaluate_or_original(&self, type_id: TypeId) -> TypeId
Evaluate a type and return the result, falling back to the original type.
This is a convenience method that unwraps the ApplicationResult.
Auto Trait Implementations§
impl<'a, R> !Freeze for ApplicationEvaluator<'a, R>
impl<'a, R> !RefUnwindSafe for ApplicationEvaluator<'a, R>
impl<'a, R> !Send for ApplicationEvaluator<'a, R>
impl<'a, R> !Sync for ApplicationEvaluator<'a, R>
impl<'a, R> Unpin for ApplicationEvaluator<'a, R>
impl<'a, R> UnsafeUnpin for ApplicationEvaluator<'a, R>
impl<'a, R> !UnwindSafe for ApplicationEvaluator<'a, R>
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