pub trait TypeResolver<E> {
// Required methods
fn source_manager(&self) -> Arc<dyn SourceManager>;
fn resolve_local_failed(&self, err: SymbolResolutionError) -> E;
fn get_type(
&self,
context: SourceSpan,
gid: GlobalItemIndex,
) -> Result<Type, E>;
fn get_local_type(
&self,
context: SourceSpan,
id: ItemIndex,
) -> Result<Option<Type>, E>;
fn resolve_type_ref(&self, ty: Span<&Path>) -> Result<SymbolResolution, E>;
// Provided method
fn resolve(&self, ty: &TypeExpr) -> Result<Option<Type>, E> { ... }
}Expand description
Abstracts over resolving an item to a concrete Type, using one of:
- A GlobalItemIndex
- An ItemIndex
- A Path
- A TypeExpr
Since type resolution happens in two different contexts during assembly, this abstraction allows us to share more of the resolution logic in both places.
Required Methods§
fn source_manager(&self) -> Arc<dyn SourceManager>
Sourcefn resolve_local_failed(&self, err: SymbolResolutionError) -> E
fn resolve_local_failed(&self, err: SymbolResolutionError) -> E
Should be called by consumers of this resolver to convert a SymbolResolutionError to the error type used by the TypeResolver implementation.
Sourcefn get_type(&self, context: SourceSpan, gid: GlobalItemIndex) -> Result<Type, E>
fn get_type(&self, context: SourceSpan, gid: GlobalItemIndex) -> Result<Type, E>
Get the Type corresponding to the item given by gid
Sourcefn get_local_type(
&self,
context: SourceSpan,
id: ItemIndex,
) -> Result<Option<Type>, E>
fn get_local_type( &self, context: SourceSpan, id: ItemIndex, ) -> Result<Option<Type>, E>
Get the Type corresponding to the item in the current module given by id
Sourcefn resolve_type_ref(&self, ty: Span<&Path>) -> Result<SymbolResolution, E>
fn resolve_type_ref(&self, ty: Span<&Path>) -> Result<SymbolResolution, E>
Attempt to resolve a symbol path, given by a TypeExpr::Ref, to an item