-
Notifications
You must be signed in to change notification settings - Fork 582
Replace class_flatten with CFGBuilder #9777
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
Open
jez
wants to merge
16
commits into
master
Choose a base branch
from
jez-no-static-init
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+3,466
−4,116
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0c4b1bf to
7ccd8f3
Compare
This doesn't actually matter for us, because we don't allow putting a sig on a `<static-init>` and thus you can't actually use the result of evaluating a class def. But I'm working on a change that removes class_flatten, and it's easier to model the "true" Ruby behavior where the last thing is returned, than it is to model the current behavior. So for the sake of showing the change to the exp files, I want to make this as a separate change.
7ccd8f3 to
d4e1edc
Compare
Collaborator
Author
|
We have a policy of testing changes to Sorbet against Stripe's codebase before Stripe employees can see the build results here: → https://go/builds/bui_Td3LgyKRdDigej |
d4e1edc to
49be9e7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
This change makes CFG builder directly desugar a
ClassDef::rhs, without firstneeding to collect all code into
MethodDefbodies.This should be a performance optimization on its own, because it means we do one
less traversal of the tree and don't do all the allocating/moving/sorting of
classes.
It also removes the last place where we are mutating the trees post resolver,
which means after this we can start caching the resolved trees. Another alternative I considered to achieve this was to simply move
class_flattenintoresolve, but that would mean bloating the blockingTypechecking...time, preventing us from getting toTypechecking in background...sooner.The other thing that
class_flattendid was to remove all theClassDefnesting structure. It's not clear that we necessarily need that. The only thing
I could think it would do is a performance optimization in stack depth of the
definition_validator and CFGCollectorAndTyper traversals? But the absolute
amount of code that would need to be traversed doesn't change, so I'm not sure
that matters in practice.
Test plan
See included automated tests.