}
TyTy::BaseType *
-TypeCheckItem::ResolveImplBlockSelfWithInference (HIR::ImplBlock &impl,
- Location locus)
+TypeCheckItem::ResolveImplBlockSelfWithInference (
+ HIR::ImplBlock &impl, Location locus,
+ TyTy::SubstitutionArgumentMappings *infer_arguments)
{
TypeCheckItem resolver;
}
// create argument mappings
- TyTy::SubstitutionArgumentMappings infer_arguments (std::move (args), {},
- locus);
+ *infer_arguments
+ = TyTy::SubstitutionArgumentMappings (std::move (args), {}, locus);
- return SubstMapperInternal::Resolve (self, infer_arguments);
+ TyTy::BaseType *infer = SubstMapperInternal::Resolve (self, *infer_arguments);
+
+ // we only need to apply to the bounds manually on types which dont bind
+ // generics
+ if (!infer->has_subsititions_defined ())
+ {
+ for (auto &bound : infer->get_specified_bounds ())
+ bound.handle_substitions (*infer_arguments);
+ }
+
+ return infer;
}
void
static TyTy::BaseType *ResolveImplBlockSelf (HIR::ImplBlock &impl_block);
- static TyTy::BaseType *
- ResolveImplBlockSelfWithInference (HIR::ImplBlock &impl, Location locus);
+ static TyTy::BaseType *ResolveImplBlockSelfWithInference (
+ HIR::ImplBlock &impl, Location locus,
+ TyTy::SubstitutionArgumentMappings *infer_arguments);
void visit (HIR::Module &module) override;
void visit (HIR::Function &function) override;
bool found_impl_trait
= context->lookup_associated_trait_impl (impl_block_id,
&associated);
+
+ auto mappings = TyTy::SubstitutionArgumentMappings::error ();
TyTy::BaseType *impl_block_ty
= TypeCheckItem::ResolveImplBlockSelfWithInference (
- *associated_impl_block, seg.get_locus ());
+ *associated_impl_block, seg.get_locus (), &mappings);
+
+ // we need to apply the arguments to the segment type so they get
+ // unified properly
+ if (!mappings.is_error ())
+ tyseg = SubstMapperInternal::Resolve (tyseg, mappings);
prev_segment = unify_site (seg.get_mappings ().get_hirid (),
TyTy::TyWithLocation (prev_segment),
-// { dg-additional-options "-frust-compile-until=nameresolution" }
pub enum Option<T> {
None,
Some(T),
}
pub trait TryFrom<T> {
- /// The type returned in the event of a conversion error.
type Error;
- /// Performs the conversion.
fn try_from(value: T) -> Result<Self, Self::Error>;
}