Use register_dynamic for merging #18028
Open
+47
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
I found a bug while working on #17871. When required components are registered, ones that are more specific (smaller inheritance depth) are preferred to others. So, if a ComponentA is already required, but it is registered as required again, it will be updated if and only if the new requirement has a smaller inheritance depth (is more specific). However, this logic was not reflected in merging
RequriedComponents
s together. Hence, for complicated requirement trees, the wrong initializer could be used.Solution
Re-write merging to work by extending the collection via
require_dynamic
instead of blindly combining the inner storage.Testing
I created this test to ensure this bug doesn't creep back in. This test fails on main, but passes on this branch.
Note that when the inheritance depth is 0 (Like if there were no middle man above), the order of the components in the bundle still matters.
Does this need a Migration Guide?
I don't believe this needs a migration guide since it's a bug fix, but it could break user's complex requirement tree if they depended on the bug. If I should add this, let me know.