Fix construction of PseudoModules to have correct parent #5012
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.
This is mostly used when constructing PseudoModules when looking up Instances within other Instances or Definitions. Previously, we would construct the PseudoModule then manually set the _parent field. The problem with this is that _parent is used during construction of the object and defaults to Builder.currentModule. Instead, we properly set the Builder state to hold the desired _parent and then construct the PseudoModule.
This also cleaned up tech debt in Module.do_pseudo_apply which duplicated logic from the standard Module.apply path in a way that had already gotten out of sync and likely would result in other very subtle bugs.
Fixes #5011
Contributor Checklist
docs/src?Type of Improvement
Desired Merge Strategy
Release Notes
This fixes subtle bugs where accessing children of an
Instance(whether directly or by usingSelectAPIs) could change the result of futureSelectto be incorrect. For example, a call toSelect.unsafe.allCurrentInstancesIncould causeSelect.unsafe.currentInstancesInto also incorrectly include grandchildren and all other transitive children.Reviewer Checklist (only modified by reviewer)
3.6.x,5.x, or6.xdepending on impact, API modification or big change:7.0)?Enable auto-merge (squash)and clean up the commit message.Create a merge commit.