Opportunistically resolve specializations during solving

This commit is contained in:
Ayaz Hafiz 2022-05-09 12:53:46 -04:00
parent f07c56a25d
commit da00c47102
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
10 changed files with 185 additions and 57 deletions

View file

@ -169,16 +169,15 @@ impl DeferredMustImplementAbility {
pub fn type_implementing_member(
specialization_must_implement_constraints: &MustImplementConstraints,
ability: Symbol,
) -> Symbol {
debug_assert_eq!({
) -> Option<Symbol> {
debug_assert!({
specialization_must_implement_constraints
.clone()
.get_unique()
.into_iter()
.filter(|mia| mia.ability == ability)
.count()
},
1,
} < 2,
"Multiple variables bound to an ability - this is ambiguous and should have been caught in canonicalization: {:?}",
specialization_must_implement_constraints
);
@ -186,8 +185,7 @@ pub fn type_implementing_member(
specialization_must_implement_constraints
.iter_for_ability(ability)
.next()
.unwrap()
.typ
.map(|mia| mia.typ)
}
pub fn resolve_ability_specialization(
@ -212,7 +210,7 @@ pub fn resolve_ability_specialization(
subs.rollback_to(snapshot);
let specializing_type =
type_implementing_member(&must_implement_ability, member_def.parent_ability);
type_implementing_member(&must_implement_ability, member_def.parent_ability)?;
let specialization = abilities_store.get_specialization(ability_member, specializing_type)?;