Skip to content

[Async Refactoring] Add return keyword if wrapping ReturnStmt is implicit #38191

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jul 1, 2021

Previously, in the following case we were failing to add a return keyword inside withImplicitReturn.

func withImplicitReturn(completionHandler: (String) -> Void) {
  simple {
    completionHandler($0)
  }
}

This is because the call of completionHandler($0) is wrapped by an implicit ReturnStmt and thus we assumed that there was already a return keyword present.

Fix this issue by checking if the wrapping ReturnStmt is implicit and if it is, add the return keyword.

Fixes rdar://80009760

…implicit

Previously, in the following case we were failing to add a `return` keyword inside `withImplicitReturn`.
```
func withImplicitReturn(completionHandler: (String) -> Void) {
  simple {
    completionHandler($0)
  }
}
```

This is because the call of `completionHandler($0)` is wrapped by an implicit `ReturnStmt` and thus we assumed that there was already a `return` keyword present.

Fix this issue by checking if the wrapping `ReturnStmt` is implicit and if it is, add the `return` keyword.

Fixes rdar://80009760
@ahoppen ahoppen requested a review from bnbarham July 1, 2021 08:23
@ahoppen
Copy link
Member Author

ahoppen commented Jul 1, 2021

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Jul 1, 2021

Windows failure is unrelated.

@ahoppen ahoppen merged commit 7a68a1d into swiftlang:main Jul 1, 2021
@ahoppen ahoppen deleted the pr/implict-return-async-refactoring branch July 5, 2021 09:15
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