mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Don't attempt to merge multiple class definitions. (#3947)
Mutating classes after they're complete leads to inconsistencies such as complete class types that have incomplete class definitions. Closes #3945
This commit is contained in:
@@ -68,6 +68,11 @@ static auto MergeClassRedecl(Context& context, SemIRLoc new_loc,
|
||||
.is_extern = prev_is_extern},
|
||||
prev_import_ir_id);
|
||||
|
||||
if (new_is_definition && prev_class.is_defined()) {
|
||||
// Don't attempt to merge multiple definitions.
|
||||
return false;
|
||||
}
|
||||
|
||||
// The introducer kind must match the previous declaration.
|
||||
// TODO: The rule here is not yet decided. See #3384.
|
||||
if (prev_class.inheritance_kind != new_class.inheritance_kind) {
|
||||
|
||||
Reference in New Issue
Block a user