Create LoadedImportRefs for vtable entries with import insts instead of local insts (#5931)

With help from Richard Smith debugging/identifying this.

Hmm - looks like maybe the Self type import ref may have the same
problem? (or at least it seems to have the same quirk in the semir dump,
where the inst id is mentioned in the `import_ref` insts, but is not
defined elsewhere, has no name, and says `[no loc]`. I'll look into that
separately. (hmm, maybe this is just an unloaded ImportRef, actually)
This commit is contained in:
David Blaikie
2025-08-11 19:29:59 +00:00
committed by GitHub
parent 5b328da0aa
commit efbc9f7c9c
2 changed files with 22 additions and 20 deletions
+6 -4
View File
@@ -2003,18 +2003,20 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
return ResolveResult::Retry();
}
for (auto& vtable_entry_id : lazy_virtual_functions) {
for (auto [import_vtable_entry_inst_id, local_vtable_entry_inst_id] :
llvm::zip(virtual_functions, lazy_virtual_functions)) {
// Use LoadedImportRef for imported symbolic constant vtable entries so they
// can carry attached constants necessary for applying specifics to these
// constants when they are used.
auto local_attached_constant_id =
resolver.local_constant_values().Get(vtable_entry_id);
resolver.local_constant_values().GetAttached(
local_vtable_entry_inst_id);
if (local_attached_constant_id.is_symbolic()) {
vtable_entry_id = AddLoadedImportRef(
local_vtable_entry_inst_id = AddLoadedImportRef(
resolver,
GetSingletonType(resolver.local_context(),
SemIR::SpecificFunctionType::TypeInstId),
vtable_entry_id, local_attached_constant_id);
import_vtable_entry_inst_id, local_attached_constant_id);
}
}