pub fn localize<'a>(ety_env: &mut ExpandEnv<'a>, env: &mut Env<'a>, dty: Ty<'a>) -> Ty<'a> {
    let bld = env.builder();
    let Ty(r, dty) = dty;
    match dty {
        Ty_::Tprim(p) => bld.prim(r, (*p).clone()),
        // TODO(hrust) missing matches
        Ty_::Tgeneric(name) => match ety_env.substs.find(&&name[..]) {
            None => bld.generic(r, &name),
            Some(ty) => {
                let ty = env.inference_env.expand_type(ty);
                let r = bld.mk_rinstantiate(ty.get_reason(), &name, r);
                Ty::mk(r, ty.get_node())
            }
        },
        // TODO(hrust) missing matches
        Ty_::Tapply(&(cls, tys)) => {
            let Id(_, cls_name) = cls;
            let tys = match env.genv.provider.get_class(&cls_name) {
                None => {
                    bld.slice_from_iter(tys.iter().copied().map(|ty| localize(ety_env, env, ty)))
                }
                Some(class_info) => {
                    // TODO(hrust) global inference logic
                    // TODO(hrust) will the `unwrap` below panic?
                    // Assumption: r is always Rhint or at least always has a pos
                    localize_tparams(ety_env, env, r.pos.unwrap(), tys, class_info.tparams)
                }
            };
            bld.class(r, cls, tys)
        }
        Ty_::Tfun(ft) => {
            let instantiation = None;
            let ft = localize_ft(ety_env, env, ft, instantiation);
            bld.fun(r, ft)
        }
        _ => {
            // TODO(hrust) missing matches
            unimplemented!("{:#?}", dty)
        }
    }
}
/// Transforms a declaration phase type into a localized type. This performs
/// common operations that are necessary for this operation, specifically:
///   > Expand newtype/types
///   > Resolves the "this" type
///   > Instantiate generics
///   > ...
///
/// When keep track of additional information while localizing a type such as
/// what type defs were expanded to detect potentially recursive definitions..
Transforms a declaration phase type into a localized type. This performs
common operations that are necessary for this operation, specifically:
> Expand newtype/types
> Resolves the "this" type
> Instantiate generics
>

When keep track of additional information while localizing a type such as
what type defs were expanded to detect potentially recursive definitions
Transforms a declaration phase type into a localized type . This performs common operations that are necessary for this operation specifically : > Expand newtype / types > Resolves the " this " type > Instantiate generics > When keep track of additional information while localizing a type such as what type defs were expanded to detect potentially recursive definitions
pub fn localize<'a>(ety_env: &mut ExpandEnv<'a>, env: &mut Env<'a>, dty: Ty<'a>) -> Ty<'a> {
    let bld = env.builder();
    let Ty(r, dty) = dty;
    match dty {
        Ty_::Tprim(p) => bld.prim(r, (*p).clone()),
        // TODO(hrust) missing matches
        Ty_::Tgeneric(name) => match ety_env.substs.find(&&name[..]) {
            None => bld.generic(r, &name),
            Some(ty) => {
                let ty = env.inference_env.expand_type(ty);
                let r = bld.mk_rinstantiate(ty.get_reason(), &name, r);
                Ty::mk(r, ty.get_node())
            }
        },
        // TODO(hrust) missing matches
        Ty_::Tapply(&(cls, tys)) => {
            let Id(_, cls_name) = cls;
            let tys = match env.genv.provider.get_class(&cls_name) {
                None => {
                    bld.slice_from_iter(tys.iter().copied().map(|ty| localize(ety_env, env, ty)))
                }
                Some(class_info) => {
                    // TODO(hrust) global inference logic
                    // TODO(hrust) will the `unwrap` below panic?
                    // Assumption: r is always Rhint or at least always has a pos
                    localize_tparams(ety_env, env, r.pos.unwrap(), tys, class_info.tparams)
                }
            };
            bld.class(r, cls, tys)
        }
        Ty_::Tfun(ft) => {
            let instantiation = None;
            let ft = localize_ft(ety_env, env, ft, instantiation);
            bld.fun(r, ft)
        }
        _ => {
            // TODO(hrust) missing matches
            unimplemented!("{:#?}", dty)
        }
    }
}
pub fn localize < ' a > ( ety_env : & mut ExpandEnv < ' a > , env : & mut Env < ' a > , dty : Ty < ' a > ) -> Ty < ' a > { let bld = env . builder ( ) ; let Ty ( r , dty ) = dty ; match dty { Ty_ :: Tprim ( p ) => bld . prim ( r , ( * p ) . clone ( ) ) , // TODO(hrust) missing matches Ty_ :: Tgeneric ( name ) => match ety_env . substs . find ( & & name [ .. ] ) { None => bld . generic ( r , & name ) , Some ( ty ) => { let ty = env . inference_env . expand_type ( ty ) ; let r = bld . mk_rinstantiate ( ty . get_reason ( ) , & name , r ) ; Ty :: mk ( r , ty . get_node ( ) ) } } , // TODO(hrust) missing matches Ty_ :: Tapply ( & ( cls , tys ) ) => { let Id ( _ , cls_name ) = cls ; let tys = match env . genv . provider . get_class ( & cls_name ) { None => { bld . slice_from_iter ( tys . iter ( ) . copied ( ) . map ( | ty | localize ( ety_env , env , ty ) ) ) } Some ( class_info ) => { // TODO(hrust) global inference logic // TODO(hrust) will the `unwrap` below panic? // Assumption: r is always Rhint or at least always has a pos localize_tparams ( ety_env , env , r . pos . unwrap ( ) , tys , class_info . tparams ) } } ; bld . class ( r , cls , tys ) } Ty_ :: Tfun ( ft ) => { let instantiation = None ; let ft = localize_ft ( ety_env , env , ft , instantiation ) ; bld . fun ( r , ft ) } _ => { // TODO(hrust) missing matches unimplemented ! ( " " dty ) } } }
Transforms a declaration phase type into a localized type.
Transforms a declaration phase type into a localized type .
ety_env
&mut ExpandEnv<'a>
env
&mut Env<'a>
dty
Ty<'a>