TyTy::BaseType *
AssociatedImplTrait::setup_associated_types (
- const TyTy::BaseType *self, const TyTy::TypeBoundPredicate &bound)
+ const TyTy::BaseType *self, const TyTy::TypeBoundPredicate &bound,
+ TyTy::SubstitutionArgumentMappings *args)
{
// compute the constrained impl block generic arguments based on self and the
// higher ranked trait bound
// generate inference variables for these bound arguments so we can compute
// their values
Location locus;
- std::vector<TyTy::SubstitutionArg> args;
+ std::vector<TyTy::SubstitutionArg> subst_args;
for (auto &p : substitutions)
{
if (p.needs_substitution ())
{
TyTy::TyVar infer_var = TyTy::TyVar::get_implicit_infer_var (locus);
- args.push_back (TyTy::SubstitutionArg (&p, infer_var.get_tyty ()));
+ subst_args.push_back (
+ TyTy::SubstitutionArg (&p, infer_var.get_tyty ()));
}
else
{
TyTy::ParamType *param = p.get_param_ty ();
TyTy::BaseType *resolved = param->destructure ();
- args.push_back (TyTy::SubstitutionArg (&p, resolved));
+ subst_args.push_back (TyTy::SubstitutionArg (&p, resolved));
param_mappings[param->get_symbol ()] = resolved->get_ref ();
}
}
- TyTy::SubstitutionArgumentMappings infer_arguments (std::move (args), {},
- locus, param_subst_cb);
+ TyTy::SubstitutionArgumentMappings infer_arguments (std::move (subst_args),
+ {}, locus,
+ param_subst_cb);
TyTy::BaseType *impl_self_infer
= (!associated_self->is_concrete ())
? SubstMapperInternal::Resolve (associated_self, infer_arguments)
resolved_trait_item->associated_type_set (substituted);
}
+ if (args != nullptr)
+ {
+ *args = associated_type_args;
+ }
+
return self_result;
}
}
// we try to look for the real impl item if possible
+ TyTy::SubstitutionArgumentMappings args
+ = TyTy::SubstitutionArgumentMappings::error ();
HIR::ImplItem *impl_item = nullptr;
if (root->is_concrete ())
{
= lookup_associated_impl_block (specified_bound, root);
if (associated_impl_trait != nullptr)
{
- associated_impl_trait->setup_associated_types (root, specified_bound);
+ associated_impl_trait->setup_associated_types (root, specified_bound,
+ &args);
for (auto &i :
associated_impl_trait->get_impl_block ()->get_impl_items ())
return;
}
+ if (!args.is_error ())
+ {
+ // apply the args
+ translated = SubstMapperInternal::Resolve (translated, args);
+ }
+
root_resolved_node_id = impl_item->get_impl_mappings ().get_nodeid ();
}