Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared: Add a Universal Flow library and refactor TypeFlow to use it. #17863

Merged
merged 12 commits into from
Nov 6, 2024

Conversation

aschackmull
Copy link
Contributor

Universal flow is the dual of existential flow in the sense that universal quantification replaces existential quantification in the recursive step in the reachability calculation. The existing shared TypeFlow library uses universal flow in several instances to prove additional type bounds that are stricter than the given static type.

This PR extracts the core universal flow calculation from TypeFlow and puts it in a separate library, such that we can easily apply it to other use-cases beyond TypeFlow. In order to do this, I had to make some very minor tweaks to the TypeFlow predicates, so the calculated bounds are not exactly the same, but they're very close:

  • exactType should be preserved tuple-for-tuple.
  • typeFlow now includes exactType as additional bounds directly instead of accounting for these in the (prior) supportsType predicate. This simplifies things and only makes a tiny difference since the exact bounds are filtered afterwards.
  • hasUnionTypeFlow shifts slightly to put the base case on nodes rather than both nodes and edges. Again this simplifies things and only makes a tiny difference in the end when superfluous bound disjuncts are pruned.

Commit-by-commit review is encouraged - I've tried hard to break the refactoring down into easily reviewable parts.

@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Oct 29, 2024
@aschackmull aschackmull requested review from a team as code owners October 29, 2024 08:18
@aschackmull
Copy link
Contributor Author

The second commit TypeFlow: Simplify interface caused a slight semantic change which is now rectified in UniversalFlow: Skip property propagation to null nodes.

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks plausible to me.

@aschackmull aschackmull merged commit 4df4a1e into github:main Nov 6, 2024
39 checks passed
@aschackmull aschackmull deleted the shared/universal-flow branch November 6, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ Java no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants