Fix indirect import handling for functions. (#4258)

The particular test this focused on is indirect_two_file in
toolchain/check/testdata/function/definition/no_prelude/extern_library.carbon.

This removes `parent_scope_id_for_new_inst` because I think it's
returning unhelpful results. The use was at the root of incorrect
results for the indirect import chain. `name_id_for_new_inst` is
actually wrapping a union, so it's more important.

The merging of `is_extern` and `first_owning_decl_id` in
`handle_function.cpp` feels like it's less correct with the changes
that've been made to `extern`. This ripples in tests, because the error
recovery shifts.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Jon Ross-Perkins
2024-08-27 20:26:23 +00:00
committed by GitHub
co-authored by Richard Smith
parent 2a7c2c5df2
commit bed5fdcbbe
16 changed files with 139 additions and 79 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ static auto MergeClassRedecl(Context& context, SemIRLoc new_loc,
(prev_class.is_extern && !new_class.is_extern)) {
prev_class.first_owning_decl_id = new_class.first_owning_decl_id;
ReplacePrevInstForMerge(
context, prev_class.parent_scope_id, prev_class.name_id,
context, new_class.parent_scope_id, prev_class.name_id,
new_is_import ? new_loc.inst_id : new_class.first_owning_decl_id);
}
return true;