Allow witness tables to support aliases and other types of StructValue (#7738)

Changing the check from "is `FunctionDecl`" to "has `FunctionType`"
provides us with more flexibilty to use aliases and other types of
`StructValue`.
This commit is contained in:
Christopher Di Bella
2026-09-09 19:35:43 +00:00
committed by GitHub
parent e090a0ef65
commit 431e349757
4 changed files with 463 additions and 324 deletions
+2 -3
View File
@@ -50,9 +50,8 @@ auto CheckAssociatedFunctionImplementation(
Context& context, SemIR::FunctionType interface_function_type,
SemIR::SpecificId enclosing_specific_id, SemIR::InstId impl_decl_id,
bool defer_thunk_definition) -> SemIR::InstId {
auto impl_function_decl =
context.insts().TryGetAs<SemIR::FunctionDecl>(impl_decl_id);
if (!impl_function_decl) {
auto impl_function_decl = context.insts().Get(impl_decl_id).type_id();
if (!context.types().Is<SemIR::FunctionType>(impl_function_decl)) {
if (impl_decl_id != SemIR::ErrorInst::InstId) {
CARBON_DIAGNOSTIC(ImplFunctionWithNonFunction, Error,
"associated function {0} implemented by non-function",