mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Refactor CheckIsAllowedRedecl and stop function definition merging (#4800)
Rename `CheckIsAllowedRedecl` to `DiagnoseIfInvalidRedecl` to try to better document behavior, and clean up comments. This extends the no-merge-if-defined behavior to functions. It was already the case for class/interface, and just added for impl, so if anything functions were now inconsistent. I was kind of tempted to make a helper for it, but I didn't think of a great structure/name to get there: `DiagnoseRedef` isn't always called when it's a redefinition, for example due to `extern` diagnostics, it's hard to combine. Cleans up `is_defined` calls to rely more on `has_definition_started`, removing some code paths that are unused since definitions aren't merged.
This commit is contained in:
@@ -453,10 +453,7 @@ auto HandleParseNode(Context& context, Parse::ImplDefinitionStartId node_id)
|
||||
impl_decl_id, impl_info.scope_id,
|
||||
context.generics().GetSelfSpecific(impl_info.generic_id));
|
||||
StartGenericDefinition(context);
|
||||
|
||||
if (!impl_info.is_defined()) {
|
||||
ImplWitnessStartDefinition(context, impl_info);
|
||||
}
|
||||
ImplWitnessStartDefinition(context, impl_info);
|
||||
context.inst_block_stack().Push();
|
||||
context.node_stack().Push(node_id, impl_id);
|
||||
|
||||
@@ -479,11 +476,9 @@ auto HandleParseNode(Context& context, Parse::ImplDefinitionId /*node_id*/)
|
||||
context.node_stack().Pop<Parse::NodeKind::ImplDefinitionStart>();
|
||||
|
||||
auto& impl_info = context.impls().Get(impl_id);
|
||||
if (!impl_info.is_defined()) {
|
||||
FinishImplWitness(context, impl_info);
|
||||
impl_info.defined = true;
|
||||
}
|
||||
|
||||
CARBON_CHECK(!impl_info.is_defined());
|
||||
FinishImplWitness(context, impl_info);
|
||||
impl_info.defined = true;
|
||||
FinishGenericDefinition(context, impl_info.generic_id);
|
||||
|
||||
context.inst_block_stack().Pop();
|
||||
|
||||
Reference in New Issue
Block a user