Add default fns and final fns to the eval block for a generic impl (#7817)

When a generic impl uses a default or final fn, it picks the specific
function value out of the interface to put in the witness table.
However, because this is done by modifying an existing instruction
block, the generics machinery has no hook to convert the function
constant into an attached constant, and because it was found in a
specific for a different generic, the constant inst will be unattached.
Fix this by manually mapping to an attached constant inst in the current
generic when building the witness table.
This commit is contained in:
Richard Smith
2026-09-23 01:19:28 +00:00
committed by GitHub
parent 53b7cfbaba
commit efbe1d2489
3 changed files with 401 additions and 80 deletions
+5 -1
View File
@@ -736,7 +736,11 @@ auto FinishImplWitness(Context& context, const SemIR::Impl& impl) -> void {
}
if (fn.interface_modifier != InterfaceModifier::None) {
witness_value = decl_id;
// We are updating the impl witness table in-place, and we pulled this
// instruction out of a constant value in a different generic, so
// manually ensure the new value gets added to the eval block.
witness_value =
GetOrAddInstWithSpecificConstantValue(context, decl_id);
break;
} else {
CARBON_DIAGNOSTIC(