From 0d9b7508e5de1ca7befef493ed3e357b8a5613a1 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 22 Oct 2024 09:17:05 -0700 Subject: [GC] Fix assertion in GlobalTypeOptimization about public super (#7026) We only checked for the case of the immediate super being public while we are private, but it might be a grandsuper instead. That is, any ancestor that is public will prevent GTO from removing a field (since we can only add fields on top of our ancestors). Also, the ancestors might not all have the field, which would add more complexity to that particular assertion, so just remove it, and add comprehensive tests. --- src/passes/GlobalTypeOptimization.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/passes/GlobalTypeOptimization.cpp b/src/passes/GlobalTypeOptimization.cpp index 74107f9cd..e35e30ac8 100644 --- a/src/passes/GlobalTypeOptimization.cpp +++ b/src/passes/GlobalTypeOptimization.cpp @@ -311,15 +311,10 @@ struct GlobalTypeOptimization : public Pass { keptFieldsNotInSuper.push_back(i); } } else { - // The super kept this field, so we must keep it as well. The - // propagation analysis above ensures that we and the super are in - // agreement on keeping it (the reasons that prevent optimization - // propagate to both), except for the corner case of the parent - // being public but us being private (the propagation does not - // take into account visibility). - assert( - !removableIndexes.count(i) || - (publicTypesSet.count(*super) && !publicTypesSet.count(type))); + // The super kept this field, so we must keep it as well. This can + // happen when we need the field in both, but also in the corner + // case where we don't need the field but the super is public. + // We need to keep it at the same index so we remain compatible. indexesAfterRemoval[i] = superIndex; // Update |next| to refer to the next available index. Due to -- cgit v1.2.3