Skip to content

[5.5][Refactoring] Avoid redeclarations or shadowing in async refactored code #37400

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
May 13, 2021

Conversation

bnbarham
Copy link
Contributor

Cherry-picking #37302


When converting a call or function, rename declarations such that
redeclaration errors and shadowing are avoided. In some cases this will
be overly conservative, but since any renamed variable can be fixed with
edit all in scope, this is preferred over causing redeclaration errors
or possible shadowing.

Resolves rdar://73973517

When converting a call or function, rename declarations such that
redeclaration errors and shadowing are avoided. In some cases this will
be overly conservative, but since any renamed variable can be fixed with
edit all in scope, this is preferred over causing redeclaration errors
or possible shadowing.

Resolves rdar://73973517
@bnbarham bnbarham requested a review from akyrtzi May 13, 2021 08:07
@bnbarham bnbarham added the r5.5 label May 13, 2021
@bnbarham bnbarham changed the title [Refactoring] Avoid redeclarations or shadowing in async refactored code [5.5][Refactoring] Avoid redeclarations or shadowing in async refactored code May 13, 2021
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cdf958c

@bnbarham
Copy link
Contributor Author

@swift-ci please test Linux platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cdf958c

@bnbarham
Copy link
Contributor Author

Another spurious failure..

@swift-ci please test Linux platform

@bnbarham
Copy link
Contributor Author

@swift-ci please nominate

--- CCC ---

Explanation: When performing the convert to async refactoring (whether on a call or function), declarations are hoisted out of the closure and into the parent scope. This can introduce potential redeclarations and/or shadowing. It's also actually a common occurrence in completion handler code - nested calls often have the same name closure argument names, eg. "res"/"result".

This change renames the declarations in hoisted code so that redeclarations/shadowing are avoided.

Radar/SR Issue: rdar://73973517

Risk: Low - only affects the async refactoring

Testing: Added new test cases to the refactoring test suite

@bnbarham bnbarham requested a review from airspeedswift May 13, 2021 12:30
@airspeedswift airspeedswift merged commit 9b15a61 into swiftlang:release/5.5 May 13, 2021
@bnbarham bnbarham deleted the cherry-rdar73973517 branch May 13, 2021 22:23
@AnthonyLatsis AnthonyLatsis added swift 5.5 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants