mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Use ImplKey in abilities store public API
This commit is contained in:
parent
923341ec95
commit
28c1a4cb95
6 changed files with 48 additions and 50 deletions
|
@ -394,7 +394,10 @@ impl ObligationCache<'_> {
|
|||
for &member in members_of_ability {
|
||||
if self
|
||||
.abilities_store
|
||||
.get_implementation(member, opaque)
|
||||
.get_implementation(roc_can::abilities::ImplKey {
|
||||
opaque,
|
||||
ability_member: ability,
|
||||
})
|
||||
.is_none()
|
||||
{
|
||||
let root_data = self.abilities_store.member_def(member).unwrap();
|
||||
|
@ -671,7 +674,12 @@ pub fn resolve_ability_specialization(
|
|||
|
||||
let resolved = match obligated {
|
||||
Obligated::Opaque(symbol) => {
|
||||
match abilities_store.get_implementation(ability_member, symbol)? {
|
||||
let impl_key = roc_can::abilities::ImplKey {
|
||||
opaque: symbol,
|
||||
ability_member,
|
||||
};
|
||||
|
||||
match abilities_store.get_implementation(impl_key)? {
|
||||
roc_types::types::MemberImpl::Impl(spec_symbol) => {
|
||||
Resolved::Specialization(*spec_symbol)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::solve::{self, Aliases};
|
||||
use roc_can::abilities::{AbilitiesStore, ImplKey, ResolvedImpl};
|
||||
use roc_can::abilities::{AbilitiesStore, ResolvedImpl};
|
||||
use roc_can::constraint::{Constraint as ConstraintSoa, Constraints};
|
||||
use roc_can::expr::PendingDerives;
|
||||
use roc_can::module::{ExposedByModule, ResolvedImplementations, RigidVariables};
|
||||
|
@ -190,16 +190,14 @@ pub fn extract_module_owned_implementations(
|
|||
) -> ResolvedImplementations {
|
||||
abilities_store
|
||||
.iter_declared_implementations()
|
||||
.filter_map(|((member, typ), member_impl)| {
|
||||
.filter_map(|(impl_key, member_impl)| {
|
||||
// This module solved this specialization if either the member or the type comes from the
|
||||
// module.
|
||||
if member.module_id() != module_id && typ.module_id() != module_id {
|
||||
if impl_key.ability_member.module_id() != module_id
|
||||
&& impl_key.opaque.module_id() != module_id
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let impl_key = ImplKey {
|
||||
opaque: typ,
|
||||
ability_member: member,
|
||||
};
|
||||
|
||||
let resolved_impl = match member_impl {
|
||||
MemberImpl::Impl(impl_symbol) => {
|
||||
|
|
|
@ -1855,7 +1855,7 @@ fn check_ability_specialization(
|
|||
};
|
||||
|
||||
abilities_store
|
||||
.mark_implementation(impl_key.ability_member, impl_key.opaque, resolved_mark)
|
||||
.mark_implementation(impl_key, resolved_mark)
|
||||
.expect("marked as a custom implementation, but not recorded as such");
|
||||
}
|
||||
}
|
||||
|
@ -2310,8 +2310,12 @@ fn get_specialization_lambda_set_ambient_function<P: Phase>(
|
|||
let opaque_home = opaque.module_id();
|
||||
let external_specialized_lset =
|
||||
phase.with_module_abilities_store(opaque_home, |abilities_store| {
|
||||
let impl_key = roc_can::abilities::ImplKey {
|
||||
opaque,
|
||||
ability_member,
|
||||
};
|
||||
let opt_specialization =
|
||||
abilities_store.get_implementation(ability_member, opaque);
|
||||
abilities_store.get_implementation(impl_key);
|
||||
match (P::IS_LATE, opt_specialization) {
|
||||
(false, None) => {
|
||||
// doesn't specialize, we'll have reported an error for this
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue