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:
Geoff Romer
2024-05-10 21:13:35 +00:00
committed by GitHub
parent 67dfe91ce3
commit c7e4cb2c76
5 changed files with 154 additions and 41 deletions
+5
View File
@@ -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) {