fn convert_tapply_to_tgeneric(&self, ty: Ty<'a>) -> Ty<'a> {
        let ty_ = match *ty.1 {
            Ty_::Tapply(&(id, targs)) => {
                let converted_targs = self.slice(
                    targs
                        .iter()
                        .map(|&targ| self.convert_tapply_to_tgeneric(targ)),
                );
                match self.tapply_should_be_tgeneric(ty.0, id) {
                    Some(name) => Ty_::Tgeneric(self.alloc((name, converted_targs))),
                    None => Ty_::Tapply(self.alloc((id, converted_targs))),
                }
            }
            Ty_::Tarray(&(tk, tv)) => Ty_::Tarray(self.alloc((
                tk.map(|tk| self.convert_tapply_to_tgeneric(tk)),
                tv.map(|tv| self.convert_tapply_to_tgeneric(tv)),
            ))),
            Ty_::Tlike(ty) => Ty_::Tlike(self.convert_tapply_to_tgeneric(ty)),
            Ty_::TpuAccess(&(ty, id)) => {
                Ty_::TpuAccess(self.alloc((self.convert_tapply_to_tgeneric(ty), id)))
            }
            Ty_::Toption(ty) => Ty_::Toption(self.convert_tapply_to_tgeneric(ty)),
            Ty_::Tfun(fun_type) => {
                let convert_param = |param: &'a FunParam<'a>| {
                    self.alloc(FunParam {
                        type_: PossiblyEnforcedTy {
                            enforced: param.type_.enforced,
                            type_: self.convert_tapply_to_tgeneric(param.type_.type_),
                        },
                        rx_annotation: param.rx_annotation.clone(),
                        ..*param
                    })
                };
                let arity = match fun_type.arity {
                    FunArity::Fstandard => FunArity::Fstandard,
                    FunArity::Fvariadic(param) => FunArity::Fvariadic(convert_param(param)),
                };
                let params = self.slice(fun_type.params.iter().cloned().map(convert_param));
                let implicit_params = fun_type.implicit_params.clone();
                let ret = PossiblyEnforcedTy {
                    enforced: fun_type.ret.enforced,
                    type_: self.convert_tapply_to_tgeneric(fun_type.ret.type_),
                };
                Ty_::Tfun(self.alloc(FunType {
                    arity,
                    params,
                    implicit_params,
                    ret,
                    reactive: fun_type.reactive.clone(),
                    ..*fun_type
                }))
            }
            Ty_::Tshape(&(kind, fields)) => {
                let mut converted_fields =
                    AssocListMut::with_capacity_in(fields.len(), self.state.arena);
                for (name, ty) in fields.iter() {
                    converted_fields.insert(
                        name.clone(),
                        ShapeFieldType {
                            optional: ty.optional,
                            ty: self.convert_tapply_to_tgeneric(ty.ty),
                        },
                    );
                }
                Ty_::Tshape(self.alloc((kind, converted_fields.into())))
            }
            Ty_::Tdarray(&(tk, tv)) => Ty_::Tdarray(self.alloc((
                self.convert_tapply_to_tgeneric(tk),
                self.convert_tapply_to_tgeneric(tv),
            ))),
            Ty_::Tvarray(ty) => Ty_::Tvarray(self.convert_tapply_to_tgeneric(ty)),
            Ty_::TvarrayOrDarray(&(tk, tv)) => Ty_::TvarrayOrDarray(self.alloc((
                self.convert_tapply_to_tgeneric(tk),
                self.convert_tapply_to_tgeneric(tv),
            ))),
            Ty_::Ttuple(tys) => Ty_::Ttuple(
                self.slice(
                    tys.iter()
                        .map(|&targ| self.convert_tapply_to_tgeneric(targ)),
                ),
            ),
            _ => return ty,
        };
        Ty(ty.0, self.alloc(ty_))
    }
// While we usually can tell whether to allocate a Tapply or Tgeneric based
// on our type_parameters stack, *constraints* on type parameters may
// reference type parameters which we have not parsed yet. When constructing
// a type parameter list, we use this function to rewrite the type of each
// constraint, considering the full list of type parameters to be in scope.
While we usually can tell whether to allocate a Tapply or Tgeneric based
on our type_parameters stack, *constraints* on type parameters may
reference type parameters which we have not parsed yet. When constructing
a type parameter list, we use this function to rewrite the type of each
constraint, considering the full list of type parameters to be in scope.
While we usually can tell whether to allocate a Tapply or Tgeneric based on our type_parameters stack * constraints * on type parameters may reference type parameters which we have not parsed yet . When constructing a type parameter list we use this function to rewrite the type of each constraint considering the full list of type parameters to be in scope .
fn convert_tapply_to_tgeneric(&self, ty: Ty<'a>) -> Ty<'a> {
        let ty_ = match *ty.1 {
            Ty_::Tapply(&(id, targs)) => {
                let converted_targs = self.slice(
                    targs
                        .iter()
                        .map(|&targ| self.convert_tapply_to_tgeneric(targ)),
                );
                match self.tapply_should_be_tgeneric(ty.0, id) {
                    Some(name) => Ty_::Tgeneric(self.alloc((name, converted_targs))),
                    None => Ty_::Tapply(self.alloc((id, converted_targs))),
                }
            }
            Ty_::Tarray(&(tk, tv)) => Ty_::Tarray(self.alloc((
                tk.map(|tk| self.convert_tapply_to_tgeneric(tk)),
                tv.map(|tv| self.convert_tapply_to_tgeneric(tv)),
            ))),
            Ty_::Tlike(ty) => Ty_::Tlike(self.convert_tapply_to_tgeneric(ty)),
            Ty_::TpuAccess(&(ty, id)) => {
                Ty_::TpuAccess(self.alloc((self.convert_tapply_to_tgeneric(ty), id)))
            }
            Ty_::Toption(ty) => Ty_::Toption(self.convert_tapply_to_tgeneric(ty)),
            Ty_::Tfun(fun_type) => {
                let convert_param = |param: &'a FunParam<'a>| {
                    self.alloc(FunParam {
                        type_: PossiblyEnforcedTy {
                            enforced: param.type_.enforced,
                            type_: self.convert_tapply_to_tgeneric(param.type_.type_),
                        },
                        rx_annotation: param.rx_annotation.clone(),
                        ..*param
                    })
                };
                let arity = match fun_type.arity {
                    FunArity::Fstandard => FunArity::Fstandard,
                    FunArity::Fvariadic(param) => FunArity::Fvariadic(convert_param(param)),
                };
                let params = self.slice(fun_type.params.iter().cloned().map(convert_param));
                let implicit_params = fun_type.implicit_params.clone();
                let ret = PossiblyEnforcedTy {
                    enforced: fun_type.ret.enforced,
                    type_: self.convert_tapply_to_tgeneric(fun_type.ret.type_),
                };
                Ty_::Tfun(self.alloc(FunType {
                    arity,
                    params,
                    implicit_params,
                    ret,
                    reactive: fun_type.reactive.clone(),
                    ..*fun_type
                }))
            }
            Ty_::Tshape(&(kind, fields)) => {
                let mut converted_fields =
                    AssocListMut::with_capacity_in(fields.len(), self.state.arena);
                for (name, ty) in fields.iter() {
                    converted_fields.insert(
                        name.clone(),
                        ShapeFieldType {
                            optional: ty.optional,
                            ty: self.convert_tapply_to_tgeneric(ty.ty),
                        },
                    );
                }
                Ty_::Tshape(self.alloc((kind, converted_fields.into())))
            }
            Ty_::Tdarray(&(tk, tv)) => Ty_::Tdarray(self.alloc((
                self.convert_tapply_to_tgeneric(tk),
                self.convert_tapply_to_tgeneric(tv),
            ))),
            Ty_::Tvarray(ty) => Ty_::Tvarray(self.convert_tapply_to_tgeneric(ty)),
            Ty_::TvarrayOrDarray(&(tk, tv)) => Ty_::TvarrayOrDarray(self.alloc((
                self.convert_tapply_to_tgeneric(tk),
                self.convert_tapply_to_tgeneric(tv),
            ))),
            Ty_::Ttuple(tys) => Ty_::Ttuple(
                self.slice(
                    tys.iter()
                        .map(|&targ| self.convert_tapply_to_tgeneric(targ)),
                ),
            ),
            _ => return ty,
        };
        Ty(ty.0, self.alloc(ty_))
    }
fn convert_tapply_to_tgeneric ( & self , ty : Ty < ' a > ) -> Ty < ' a > { let ty_ = match * ty . 1 { Ty_ :: Tapply ( & ( id , targs ) ) => { let converted_targs = self . slice ( targs . iter ( ) . map ( | & targ | self . convert_tapply_to_tgeneric ( targ ) ) , ) ; match self . tapply_should_be_tgeneric ( ty . 0 , id ) { Some ( name ) => Ty_ :: Tgeneric ( self . alloc ( ( name , converted_targs ) ) ) , None => Ty_ :: Tapply ( self . alloc ( ( id , converted_targs ) ) ) , } } Ty_ :: Tarray ( & ( tk , tv ) ) => Ty_ :: Tarray ( self . alloc ( ( tk . map ( | tk | self . convert_tapply_to_tgeneric ( tk ) ) , tv . map ( | tv | self . convert_tapply_to_tgeneric ( tv ) ) , ) ) ) , Ty_ :: Tlike ( ty ) => Ty_ :: Tlike ( self . convert_tapply_to_tgeneric ( ty ) ) , Ty_ :: TpuAccess ( & ( ty , id ) ) => { Ty_ :: TpuAccess ( self . alloc ( ( self . convert_tapply_to_tgeneric ( ty ) , id ) ) ) } Ty_ :: Toption ( ty ) => Ty_ :: Toption ( self . convert_tapply_to_tgeneric ( ty ) ) , Ty_ :: Tfun ( fun_type ) => { let convert_param = | param : & ' a FunParam < ' a > | { self . alloc ( FunParam { type_ : PossiblyEnforcedTy { enforced : param . type_ . enforced , type_ : self . convert_tapply_to_tgeneric ( param . type_ . type_ ) , } , rx_annotation : param . rx_annotation . clone ( ) , .. * param } ) } ; let arity = match fun_type . arity { FunArity :: Fstandard => FunArity :: Fstandard , FunArity :: Fvariadic ( param ) => FunArity :: Fvariadic ( convert_param ( param ) ) , } ; let params = self . slice ( fun_type . params . iter ( ) . cloned ( ) . map ( convert_param ) ) ; let implicit_params = fun_type . implicit_params . clone ( ) ; let ret = PossiblyEnforcedTy { enforced : fun_type . ret . enforced , type_ : self . convert_tapply_to_tgeneric ( fun_type . ret . type_ ) , } ; Ty_ :: Tfun ( self . alloc ( FunType { arity , params , implicit_params , ret , reactive : fun_type . reactive . clone ( ) , .. * fun_type } ) ) } Ty_ :: Tshape ( & ( kind , fields ) ) => { let mut converted_fields = AssocListMut :: with_capacity_in ( fields . len ( ) , self . state . arena ) ; for ( name , ty ) in fields . iter ( ) { converted_fields . insert ( name . clone ( ) , ShapeFieldType { optional : ty . optional , ty : self . convert_tapply_to_tgeneric ( ty . ty ) , } , ) ; } Ty_ :: Tshape ( self . alloc ( ( kind , converted_fields . into ( ) ) ) ) } Ty_ :: Tdarray ( & ( tk , tv ) ) => Ty_ :: Tdarray ( self . alloc ( ( self . convert_tapply_to_tgeneric ( tk ) , self . convert_tapply_to_tgeneric ( tv ) , ) ) ) , Ty_ :: Tvarray ( ty ) => Ty_ :: Tvarray ( self . convert_tapply_to_tgeneric ( ty ) ) , Ty_ :: TvarrayOrDarray ( & ( tk , tv ) ) => Ty_ :: TvarrayOrDarray ( self . alloc ( ( self . convert_tapply_to_tgeneric ( tk ) , self . convert_tapply_to_tgeneric ( tv ) , ) ) ) , Ty_ :: Ttuple ( tys ) => Ty_ :: Ttuple ( self . slice ( tys . iter ( ) . map ( | & targ | self . convert_tapply_to_tgeneric ( targ ) ) , ) , ) , _ => return ty , } ; Ty ( ty . 0 , self . alloc ( ty_ ) ) }
While we usually can tell whether to allocate a Tapply or Tgeneric based
on our type_parameters stack, *constraints* on type parameters may
reference type parameters which we have not parsed yet.
While we usually can tell whether to allocate a Tapply or Tgeneric based on our type_parameters stack * constraints * on type parameters may reference type parameters which we have not parsed yet .
&self
ty
Ty<'a>