-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Swiftify] Handle anonymous parameters #81384
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci please smoke test |
_SwiftifyImport would expand with syntax errors if applied to a function with anonymous parameters, because it would try to refer to parameters using the name `_`. Detect these cases and create names for unnamed parameters. rdar://150955944
73cfb77
to
0a37a5d
Compare
@swift-ci please smoke test |
let param = e.with(\.type, (argTypes[i] ?? e.type)!) | ||
let name = param.secondName ?? param.firstName | ||
if name.trimmed.text == "_" { |
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.
Why the redundant logic to extract the parameter name and check for _
?
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.
Ah good point!
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.
Ah this is needed for general swift syntax, e.g. if you have func foo(bar: T)
. If you just blindly do .with(\.secondName, getParamName(param, i))
, then you end up with func foo(bar bar: T))
. Which I guess is not actually a problem, just redundant. But I also don't think we can end up with that syntax from an imported C function, so that's fine.
_SwiftifyImport would expand with syntax errors if applied to a function with anonymous parameters, because it would try to refer to parameters using the name
_
. Detect these cases and create names for unnamed parameters.rdar://150955944