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

Split FunctionParameterSyntax and related types #1455

Merged
merged 1 commit into from
Apr 5, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 27, 2023

FunctionParameterSyntax was used in a number of cases (function parameter, closure parameter and enum case parameter) and because it needs to satisfy all of them all its parameters are optional. Split it into three different types that have non-optional children.

rdar://106874808

@ahoppen ahoppen requested a review from rintaro March 27, 2023 23:20
@ahoppen
Copy link
Member Author

ahoppen commented Mar 27, 2023

@swift-ci Please test

ahoppen added a commit to ahoppen/swift-stress-tester that referenced this pull request Mar 28, 2023
…r function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
ahoppen added a commit to ahoppen/swift-format that referenced this pull request Mar 28, 2023
…r function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
ahoppen added a commit to ahoppen/swift that referenced this pull request Mar 28, 2023
…r function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
ahoppen added a commit to ahoppen/swift that referenced this pull request Mar 28, 2023
… nodes for function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
ahoppen added a commit to ahoppen/swift that referenced this pull request Mar 28, 2023
…ultiple nodes for function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
@ahoppen ahoppen force-pushed the ahoppen/split-function-parameter branch from c9a3785 to 9f9f53b Compare March 28, 2023 22:31
@ahoppen
Copy link
Member Author

ahoppen commented Mar 28, 2023

@ahoppen ahoppen force-pushed the ahoppen/split-function-parameter branch from 9f9f53b to 33d4ce3 Compare March 29, 2023 16:25
@ahoppen
Copy link
Member Author

ahoppen commented Mar 29, 2023

@ahoppen
Copy link
Member Author

ahoppen commented Mar 29, 2023

@ahoppen ahoppen force-pushed the ahoppen/split-function-parameter branch from 33d4ce3 to 89d5d32 Compare March 29, 2023 22:25
@ahoppen
Copy link
Member Author

ahoppen commented Mar 29, 2023

@ahoppen ahoppen force-pushed the ahoppen/split-function-parameter branch from 89d5d32 to 1621138 Compare March 30, 2023 15:19
@ahoppen
Copy link
Member Author

ahoppen commented Mar 30, 2023

ahoppen added a commit to ahoppen/swift that referenced this pull request Mar 30, 2023
…ultiple nodes for function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
ahoppen added a commit to ahoppen/swift-format that referenced this pull request Mar 31, 2023
…r function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
@ahoppen
Copy link
Member Author

ahoppen commented Mar 31, 2023

ahoppen added a commit to ahoppen/swift-format that referenced this pull request Mar 31, 2023
…r function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
@ahoppen
Copy link
Member Author

ahoppen commented Mar 31, 2023

@ahoppen
Copy link
Member Author

ahoppen commented Mar 31, 2023

@ahoppen
Copy link
Member Author

ahoppen commented Mar 31, 2023

@ahoppen ahoppen requested a review from bnbarham March 31, 2023 19:31
// MARK: Parameter parsing

extension Parser {
mutating func parseFunctionParameter() -> RawFunctionParameterSyntax {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a fair bit of duplication between these. Did you find that made more sense then having options on a parseParameterLikeDecl(...) sort of function? RawParameterTrait could include an init that just has alllll the things, where we ignore params that don't make sense where necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to get the compile-time safety of not forgetting to pass one of the required arguments and I think we can only reasonably to do was to duplicate it.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can still have separate parseFunctionParameter etc. for callers outside. It'd just be fileprivate within Parameters.

Comment on lines -736 to -737
nameForDiagnostics: "type",
isOptional: true
Copy link
Contributor

Choose a reason for hiding this comment

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

🥳

FunctionParameterSyntax was used in a number of cases (function parameter, closure parameter and enum case parameter) and because it needs to satisfy all of them all its parameters are optional. Split it into three different types that have non-optional children.

rdar://106874808
@ahoppen ahoppen force-pushed the ahoppen/split-function-parameter branch from 1621138 to fe710b2 Compare April 4, 2023 21:36
@ahoppen
Copy link
Member Author

ahoppen commented Apr 4, 2023

@ahoppen
Copy link
Member Author

ahoppen commented Apr 4, 2023

1 similar comment
@ahoppen
Copy link
Member Author

ahoppen commented Apr 5, 2023

@ahoppen
Copy link
Member Author

ahoppen commented Apr 5, 2023

@ahoppen ahoppen merged commit d3c4f24 into swiftlang:main Apr 5, 2023
@ahoppen ahoppen deleted the ahoppen/split-function-parameter branch April 5, 2023 20:33
ahoppen added a commit to ahoppen/swift that referenced this pull request Apr 5, 2023
…ultiple nodes for function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
ahoppen added a commit to swiftlang/swift-format that referenced this pull request Apr 5, 2023
…r function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
ahoppen added a commit to swiftlang/swift-stress-tester that referenced this pull request Apr 5, 2023
…r function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
ahoppen added a commit to swiftlang/swift-format that referenced this pull request Apr 5, 2023
…r function parameters, closure parameters and enum parameters

Companion of swiftlang/swift-syntax#1455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants