Skip to content

Don't apply "Convert to Trailing Closure" to call with multiple trailing closures #38625

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

Merged
merged 1 commit into from
Jul 26, 2021

Conversation

hamishknight
Copy link
Contributor

The hasTrailingClosure method has a super confusing name now, as it doesn't include multiple trailing closures. This is getting fixed in #37435, but split out this change to keep that patch as NFC as possible.

Previously we'd perform an invalid transform or hit an assertion failure when attempting to perform the "Convert to Trailing Closure" refactoring action on a call with multiple trailing closures. For now, disallow the transform for a call that already uses trailing closure syntax.

rdar://81106400

@hamishknight hamishknight requested a review from rintaro July 26, 2021 14:34
…ing closures

Previously we'd perform an invalid transform or hit
an assertion failure. For now, disallow the transform
for a call that already uses trailing closure syntax.

rdar://81106400
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@swiftlang swiftlang deleted a comment from swift-ci Jul 26, 2021
@rintaro
Copy link
Member

rintaro commented Jul 26, 2021

The implementation looks good. But out of curiosity, why hasTrailingClosure() is not true for multiple trailing closure call?

@hamishknight
Copy link
Contributor Author

hamishknight commented Jul 26, 2021

@rintaro It was written before multiple trailing closures got added, and I guess it never got updated to reflect that (a bunch of callers do use it to really check for the single closure case tho). With #37435, I'm separating it out into hasSingleTrailingClosure() & hasAnyTrailingClosures().

@hamishknight hamishknight merged commit 623128a into swiftlang:main Jul 26, 2021
@hamishknight hamishknight deleted the trail-and-tuple branch July 26, 2021 20:49
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