fix: refinement subtyping bug

This commit is contained in:
Shunsuke Shibayama 2023-08-04 16:12:57 +09:00
parent 278039c75b
commit b45041e926
2 changed files with 41 additions and 15 deletions

View file

@ -912,22 +912,20 @@ impl Context {
}
fn poly_class_trait_impl_exists(&self, class: &Type, trait_: &Type) -> bool {
let mut super_exists = false;
for imp in self.get_trait_impls(trait_).into_iter() {
self.substitute_typarams(&imp.sub_type, class).unwrap_or(());
self.substitute_typarams(&imp.sup_trait, trait_)
.unwrap_or(());
if self.supertype_of(&imp.sub_type, class) && self.supertype_of(&imp.sup_trait, trait_)
{
super_exists = true;
Self::undo_substitute_typarams(&imp.sub_type);
Self::undo_substitute_typarams(&imp.sup_trait);
break;
return true;
}
Self::undo_substitute_typarams(&imp.sub_type);
Self::undo_substitute_typarams(&imp.sup_trait);
}
super_exists
false
}
fn check_trait_impl(