Old implementations can be overwritten before solving

This commit is contained in:
Ayaz Hafiz 2022-10-10 15:08:51 -05:00
parent 7298705db7
commit bd5f5ed735
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58
2 changed files with 12 additions and 2 deletions

View File

@ -504,8 +504,12 @@ impl IAbilitiesStore<Pending> {
let old_declared_impl = self.declared_implementations.insert(impl_key, member_impl);
debug_assert!(
old_declared_impl.is_none(),
"Replacing existing declared impl!"
old_declared_impl.is_none() ||
// Can happen between we import declared implementations during canonicalization, but
// implementation information only after solving
old_declared_impl.unwrap() == member_impl,
"Replacing existing declared impl: {:?}",
(impl_key, old_declared_impl)
);
}

View File

@ -345,6 +345,9 @@ fn start_phase<'a>(
)
});
// Add the declared abilities from the modules we import;
// we may not know all their types yet since type-solving happens in
// parallel, but we'll fill that in during type-checking our module.
abilities_store
.union(import_store.closure_from_imported(exposed_symbols));
}
@ -4335,6 +4338,9 @@ pub fn add_imports(
import_variables.push(list_len_type);
}
// Fill in the implementation information of the abilities from the modules we import, which we
// now know because all imported modules should be solved by now.
//
// TODO: see if we can reduce the amount of specializations we need to import.
// One idea is to just always assume external modules fulfill their specialization obligations
// and save lambda set resolution for mono.