mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user