mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-03 18:29:00 +00:00
fix: traits can have impls
This commit is contained in:
parent
cdabb2e546
commit
ebd7707f77
4 changed files with 42 additions and 1 deletions
|
@ -1435,6 +1435,32 @@ impl Context {
|
|||
attrs.guaranteed_extend(sup_ctx.type_dir(namespace));
|
||||
}
|
||||
}
|
||||
for sup in self.super_traits.iter() {
|
||||
if let Some(sup_ctx) = namespace.get_nominal_type_ctx(sup) {
|
||||
if sup_ctx.name == self.name {
|
||||
continue;
|
||||
}
|
||||
attrs.guaranteed_extend(sup_ctx.type_impl_dir(namespace));
|
||||
}
|
||||
}
|
||||
attrs
|
||||
}
|
||||
|
||||
fn type_impl_dir<'t>(&'t self, namespace: &'t Context) -> Dict<&VarName, &VarInfo> {
|
||||
let mut attrs = self.locals.iter().collect::<Dict<_, _>>();
|
||||
attrs.guaranteed_extend(
|
||||
self.methods_list
|
||||
.iter()
|
||||
.flat_map(|ctx| ctx.type_impl_dir(namespace)),
|
||||
);
|
||||
for sup in self.super_classes.iter().chain(self.super_traits.iter()) {
|
||||
if let Some(sup_ctx) = namespace.get_nominal_type_ctx(sup) {
|
||||
if sup_ctx.name == self.name {
|
||||
continue;
|
||||
}
|
||||
attrs.guaranteed_extend(sup_ctx.type_impl_dir(namespace));
|
||||
}
|
||||
}
|
||||
attrs
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue