mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:42:01 +01:00
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:
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user