Ensure vtable entries for generics are attached constants (#5853)

Otherwise these end up as unattached constants (see the baseline test
changes) and can't be resolved by `GetConstantValueInSpecific` in
lowering or in further derived vtables.

If the class is non-generic, then it's fine for the vtable entry for
some function inherited from a generic base is represented as an
unattached constant, since the specific in that specific_function is
already fully resolved.

---------

Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
David Blaikie
2025-07-28 21:06:57 +00:00
committed by GitHub
co-authored by Dana Jansens
parent 5de47962b0
commit 26ec78ec00
5 changed files with 465 additions and 5 deletions
+1 -1
View File
@@ -978,7 +978,7 @@ auto FileContext::BuildVtable(const SemIR::Vtable& vtable,
vfuncs.reserve(vtable_inst_block.size());
for (auto fn_decl_id : vtable_inst_block) {
auto [fn_decl, fn_id, fn_specific_id] =
auto [_1, _2, fn_id, fn_specific_id] =
DecomposeVirtualFunction(sem_ir(), fn_decl_id, specific_id);
vfuncs.push_back(llvm::ConstantExpr::getTrunc(