[GR-58690] Typeflow.getState() cleanup #9922
Merged
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.
Overview
This PR changes how we access the
TypeStateofTypeFlownodes. The main changes are the folowing methods on theTypeFlowclass:getState()now asserts that the flow is enabled. This is the main method that should be used in common cases.getOutputState()- whose result represents the state that is currently pushed out of the given flow along theuseedges (which will be empty for disabled flows, Any/AllInstantiated for saturated flows, and the actual type state otherwise). It is a helper method that should be used sparingly, in situations when the input flow can be in arbitrary state. We need it for example for the new flows for filtering primitives, as they have multiple input flows, and just because one of the inputs is enabled does mean the others are as well.getRawState()- the real state of the flow, without checking any flags, meant mainly for debugging, logging and other special use cases, name intentionally chosen to sound dangerous, like something one typically should not use.getStateDescription()- helper to be used intoString()methods of all the flows, returns the string representation of the state including disabled/enabled/saturation information.The rest of the PR is just updating all the usages of the old
TypeFlow.getState()method, which makes this PR look big, but most of the changes should hopefully be quick to verify.Motivation for the Change
Before this PR, the
TypeStateof every flow was queried using thegetState()method. However, after WP-SCCP was merged, it is questionable whether it makes sense to query theTypeStateof disabled flows, so we introduced accessor methods to distinguish between the main use cases, which allows us, e.g. to assert the state of the dependencies when we know from the context that they should be already enabled (if not, it suggests a bug is somewhere).