mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-19 08:50:27 +00: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:
1 parent
45ca3d28f5
commit
f63d0a6266
5 files changed
+70
-106
No files matched your search
@@ -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