Replace ResolvePrevInstForMerge with decl logic. (#3936)

This addresses the const reliance of ResolvePrevInstForMerge by checking
the imported instruction, testing with `alias` name conflicts. Given the
need to examine structure, the helper function feels like it now gets in
the way, so I'm just removing it.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Jon Ross-Perkins
2024-05-06 21:27:21 +00:00
committed by GitHub
co-authored by Richard Smith
parent d5c0c9cfe3
commit 292a9d3cb4
10 changed files with 400 additions and 97 deletions
+3 -3
View File
@@ -12,7 +12,7 @@ auto MergeClassRedecl(Context& context, SemIRLoc new_loc,
SemIR::Class& new_class, bool new_is_import,
bool new_is_definition, bool new_is_extern,
SemIR::ClassId prev_class_id, bool prev_is_extern,
SemIR::ImportIRInstId prev_import_ir_inst_id) -> bool {
SemIR::ImportIRId prev_import_ir_id) -> bool {
auto& prev_class = context.classes().Get(prev_class_id);
SemIRLoc prev_loc =
prev_class.is_defined() ? prev_class.definition_id : prev_class.decl_id;
@@ -30,7 +30,7 @@ auto MergeClassRedecl(Context& context, SemIRLoc new_loc,
{.loc = prev_loc,
.is_definition = prev_class.is_defined(),
.is_extern = prev_is_extern},
prev_import_ir_inst_id);
prev_import_ir_id);
// The introducer kind must match the previous declaration.
// TODO: The rule here is not yet decided. See #3384.
@@ -56,7 +56,7 @@ auto MergeClassRedecl(Context& context, SemIRLoc new_loc,
prev_class.object_repr_id = new_class.object_repr_id;
}
if ((prev_import_ir_inst_id.is_valid() && !new_is_import) ||
if ((prev_import_ir_id.is_valid() && !new_is_import) ||
(prev_is_extern && !new_is_extern)) {
prev_class.decl_id = new_class.decl_id;
ReplacePrevInstForMerge(