-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AST] A couple of PatternBindingInitializer cleanups #70591
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
Conversation
693a1b4
to
806beef
Compare
806beef
to
3d3b739
Compare
This stores the same state as PatternBindingInitializer, we can use that instead.
This stores the same state as DefaultArgumentInitializer, use that instead.
Switch from promising a DeclContext to a PatternBindingInitializer. This has a couple of benefits: - It eliminates a few places where we were force `cast`'ing to PatternBindingInitializer. - It improves the clarity of what's being stored, it's not whatever the parent context of the initializer is, it's specifically the PatternBindingInitializer context if it exists.
Use the PatternBindingInitializer context if we have one. This also uncovered a parser issue where we would mistakenly create a PatternBindingInitializer in top-level code after parsing the initializers.
Most clients only want to set one of the two parameters, split it into `setPattern` and `setInitContext` (the latter of which now handles calling `setBinding`).
And add some assertions to ensure we don't attempt to re-set the binding or index (the parent context can unfortunately change currently).
This could result in us changing the binding index after-the-fact.
3d3b739
to
0b18d28
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@@ -115,8 +113,6 @@ enum class DeclContextKind : unsigned { | |||
/// \see SerializedLocalDeclContext. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is out of date. Is DeclContextKind::SerializedLocal also dead now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah looks like we can probably just rip out SerializedLocalDeclContext at this point, I'll do that in a follow-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source compat failures are unrelated |
Remove
SerializedPatternBindingInitializer
&SerializedDefaultArgumentInitializer
since we can deserializePatternBindingInitializer
&DefaultArgumentInitializer
directly (as I understand it, theSerializedXXX
decl contexts only exist for cases where we don't want to serialize e.g a fullClosureExpr
/TopLevelDecl
, that doesn't apply here). This then allows us to clean upPatternBindingDecl
's handling ofPatternBindingInitializer
a bit.