Skip to content

[5.7][Refactoring] Several improvements to memberwise initializer generation #58757

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 9, 2022

  • Explanation: This contains several improvements to the “Generate Memberwise Initializer” refactoring that I’m putting up a PR because they touch very related code and would conflict with each other
    • Generating a memberwise init would skip over properties with property wrappers. Switch the implementation of memberwise init generation closer to the one that generates the implicit memberwise init by also using getMembers() instead of getStoredProperties().
    • If type has no memberwise initializable members, generate an empty initializer instead of failing.
    • Previously, we were dropping backticks, which might lead to invalid code if the type member was a keyword. Maintain any backticks from type members in the generated memberwise initializer.
  • Scope: Generate Memberwise Initializer refactoring
  • Risk: Low, only affects Generate Memberwise Initializer refactoring
  • Testing: Added regression tests
  • Issue: rdar://81888671 , rdar://89057767
  • Reviewer: @bnbarham on [Refactoring] Several improvements to memberwise initializer generation #58718

ahoppen added 4 commits May 9, 2022 17:05
…ise init

Generating a memberwise init would skip over properties with property wrappers. Switch the implementation of memberwise init generation closer to the one that generates the implicit memberwise init by also using `getMembers()` instead of `getStoredProperties()`.

rdar://89057767
…mberwise initializer

Previously, we were dropping backticks, which might lead to invalid code if the type member was a keyword.

rdar://81888671
@ahoppen ahoppen added the r5.7 label May 9, 2022
@ahoppen ahoppen requested a review from airspeedswift May 9, 2022 15:08
@ahoppen ahoppen requested a review from a team as a code owner May 9, 2022 15:08
@ahoppen
Copy link
Member Author

ahoppen commented May 9, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit 2af3fd2 into swiftlang:release/5.7 May 13, 2022
@ahoppen ahoppen deleted the pr-5.7/generate-memberwise-property-wrapper branch May 13, 2022 16:40
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.7 labels Jan 9, 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.7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants