mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
More support for generic interfaces, aiming for parity with support for generic classes. (#4034)
This is mostly mechanically duplicating work done for generic classes to also support generic interfaces. Also fix both generic interfaces and generic classes to support importing class and interface types with arguments from another file. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com> Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
Carbon Infra Bot
parent
3ade5bd8f3
commit
f772c1f5f3
@@ -65,6 +65,7 @@ static auto BuildInterfaceDecl(Context& context,
|
||||
existing_interface_decl->interface_id)))) {
|
||||
// This is a redeclaration of an existing interface.
|
||||
interface_decl.interface_id = existing_interface_decl->interface_id;
|
||||
interface_decl.type_id = existing_interface_decl->type_id;
|
||||
// TODO: If the new declaration is a definition, keep its parameter
|
||||
// and implicit parameter lists rather than the ones from the
|
||||
// previous declaration.
|
||||
@@ -81,12 +82,17 @@ static auto BuildInterfaceDecl(Context& context,
|
||||
// there was an error in the qualifier, we will have lost track of the
|
||||
// interface name here. We should keep track of it even if the name is
|
||||
// invalid.
|
||||
interface_decl.interface_id = context.interfaces().Add(
|
||||
{.name_id = name_context.name_id_for_new_inst(),
|
||||
.parent_scope_id = name_context.parent_scope_id_for_new_inst(),
|
||||
.implicit_param_refs_id = name.implicit_params_id,
|
||||
.param_refs_id = name.params_id,
|
||||
.decl_id = interface_decl_id});
|
||||
SemIR::Interface interface_info = {
|
||||
.name_id = name_context.name_id_for_new_inst(),
|
||||
.parent_scope_id = name_context.parent_scope_id_for_new_inst(),
|
||||
.implicit_param_refs_id = name.implicit_params_id,
|
||||
.param_refs_id = name.params_id,
|
||||
.decl_id = interface_decl_id};
|
||||
interface_decl.interface_id = context.interfaces().Add(interface_info);
|
||||
if (interface_info.is_generic()) {
|
||||
interface_decl.type_id =
|
||||
context.GetGenericInterfaceType(interface_decl.interface_id);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: For a generic interface declaration, set the `type_id` to a suitable
|
||||
|
||||
Reference in New Issue
Block a user