mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 09:21:04 +01:00
When re-declaring, find the original decl of an associated function in an interface (#6688)
Functions in an interface definition are wrapped in an AssociatedEntity instruction, which the logic for finding a previous declaration must unwrap to find the FunctionDecl. This is controlled by the NameScope::is_interface_definition() flag, which is true for interfaces, and causes this extra wrapping to occur when adding the function to the scope.
This commit is contained in:
@@ -195,6 +195,15 @@ static auto TryMergeRedecl(Context& context, Parse::AnyFunctionDeclId node_id,
|
||||
auto prev_type_id = SemIR::TypeId::None;
|
||||
auto prev_import_ir_id = SemIR::ImportIRId::None;
|
||||
CARBON_KIND_SWITCH(context.insts().Get(prev_id)) {
|
||||
case CARBON_KIND(SemIR::AssociatedEntity assoc_entity): {
|
||||
// This is a function in an interface definition scope (see
|
||||
// NameScope::is_interface_definition()).
|
||||
auto function_decl =
|
||||
context.insts().GetAs<SemIR::FunctionDecl>(assoc_entity.decl_id);
|
||||
prev_function_id = function_decl.function_id;
|
||||
prev_type_id = function_decl.type_id;
|
||||
break;
|
||||
}
|
||||
case CARBON_KIND(SemIR::FunctionDecl function_decl): {
|
||||
prev_function_id = function_decl.function_id;
|
||||
prev_type_id = function_decl.type_id;
|
||||
|
||||
Reference in New Issue
Block a user