TypeResolver

Trait TypeResolver 

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

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§

Source

fn source_manager(&self) -> Arc<dyn SourceManager>

Source

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.

Source

fn get_type(&self, context: SourceSpan, gid: GlobalItemIndex) -> Result<Type, E>

Get the Type corresponding to the item given by gid

Source

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

Source

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

Provided Methods§

Source

fn resolve(&self, ty: &TypeExpr) -> Result<Option<Type>, E>

Resolve a TypeExpr to a concrete Type

Implementors§