mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 07:31:04 +01:00
When merging functions, detect uses of imports prior to a redecl. (#3836)
LookupNameInDecl is only called from DeclNameStack, but I'm adding mark_imports_used there because it feels more consistent. Not sure if we want a better API boundary. I admit I'm also suspicious of its call to LookupInCurrentScope but maybe it's okay due to how imports work. I was choosing to print multiple diagnostics when a declaration is previously used _and_ doesn't match because I think the "previously used" is more important, but the "doesn't match" may give an additional hint about why it didn't work. The merge.h utility function is because I think we can follow a similar model for identifying errors with other declarations: classes, interfaces, etc.
This commit is contained in:
@@ -92,8 +92,8 @@ static auto BuildInterfaceWitness(
|
||||
auto decl = context.insts().Get(const_id.inst_id());
|
||||
if (auto fn_decl = decl.TryAs<SemIR::FunctionDecl>()) {
|
||||
auto& fn = context.functions().Get(fn_decl->function_id);
|
||||
auto impl_decl_id =
|
||||
context.LookupNameInExactScope(decl_id, fn.name_id, impl_scope);
|
||||
auto impl_decl_id = context.LookupNameInExactScope(
|
||||
decl_id, fn.name_id, impl_scope, /*mark_imports_used=*/true);
|
||||
if (impl_decl_id.is_valid()) {
|
||||
used_decl_ids.push_back(impl_decl_id);
|
||||
table.push_back(CheckAssociatedFunctionImplementation(
|
||||
|
||||
Reference in New Issue
Block a user