Store an InterfaceId and a SpecificId in AssociatedEntityType. (#5252)

Instead of storing a `TypeId` that always refer to a facet type that
always contains exactly a single interface, store the interface
directly.

Also improve stringification of `LookupImplWitness` and witness access
into it, switching to using newly-added functionality for stringifying
specific interfaces.
This commit is contained in:
Richard Smith
2025-04-05 16:08:09 +00:00
committed by GitHub
parent 8e7bb2f953
commit a45dc42d82
110 changed files with 1619 additions and 1611 deletions
+6 -4
View File
@@ -25,9 +25,10 @@ auto BuildAssociatedEntity(Context& context, SemIR::InterfaceId interface_id,
return SemIR::ErrorInst::SingletonInstId;
}
// The interface type is the type of `Self`.
auto self_type_id =
context.insts().Get(interface_info.self_param_id).type_id();
// This associated entity is being declared as a member of the self specific
// of the interface.
auto interface_specific_id =
context.generics().GetSelfSpecific(interface_info.generic_id);
// Register this declaration as declaring an associated entity.
auto index = SemIR::ElementIndex(
@@ -36,7 +37,8 @@ auto BuildAssociatedEntity(Context& context, SemIR::InterfaceId interface_id,
// Name lookup for the declaration's name should name the associated entity,
// not the declaration itself.
auto type_id = GetAssociatedEntityType(context, self_type_id);
auto type_id =
GetAssociatedEntityType(context, interface_id, interface_specific_id);
return AddInst<SemIR::AssociatedEntity>(
context, context.insts().GetLocId(decl_id),
{.type_id = type_id, .index = index, .decl_id = decl_id});