Track an interface type, not an interface ID, on an associated entity. (#4188)

This prepares us for modeling associated entities of parameterized
interfaces.

We don't use the interface parameters when type-checking `impl`s or uses
of interface members yet, but we do now check interface arguments during
`impl` lookup.
This commit is contained in:
Richard Smith
2024-08-05 20:45:14 +00:00
committed by GitHub
parent 183c8c0ccf
commit 8a8c227163
73 changed files with 729 additions and 166 deletions
+5 -1
View File
@@ -21,6 +21,10 @@ auto BuildAssociatedEntity(Context& context, SemIR::InterfaceId interface_id,
return SemIR::InstId::BuiltinError;
}
// The interface type is the type of `Self`.
auto self_type_id =
context.insts().Get(interface_info.self_param_id).type_id();
// Register this declaration as declaring an associated entity.
auto index = SemIR::ElementIndex(
context.args_type_info_stack().PeekCurrentBlockContents().size());
@@ -29,7 +33,7 @@ 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 = context.GetAssociatedEntityType(
interface_id, context.insts().Get(decl_id).type_id());
self_type_id, context.insts().Get(decl_id).type_id());
return context.AddInst<SemIR::AssociatedEntity>(
context.insts().GetLocId(decl_id),
{.type_id = type_id, .index = index, .decl_id = decl_id});