-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema/SIL] Improve diagnostics related to init accessors #66513
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci please test |
'self' within init accessor could only be used to refer to properties listed in `initializes` and `accesses` attributes.
…s within init accessors Only properties that are listed in 'initializes' and 'accesses' attributes could be referenced within init accessor. Detect any and all invalid member references in the solver.
…s within init accessors
…gnostics within init accessors
…d before every terminator This closes a hole where an early return could leave some properties from `initializes(...)` list uninitialized. For example: ```swift init(initialValue) initializes(_a, _b) { _a = initialValue.0 if _a > 0 { return } _b = initialValue.1 } ``` Here `_b` is not initialized when `_a > 0`.
… memberwise init If init accessor initialize the same properties, let's emit them in sequence and emit `destroy_addr` in-between to make sure that there is no double initialization.
… be synthesized If some of the properties with init accessors have out of order accesses diagnose that while checking whether memberwise init could be synthesized.
…tializes` intersect If some property is initializable by one than one init accessor let's not sythesize a memberwise initializer in that case because it's ambiguous what is the best init accessor to use.
…mberwise initializable
…ors should follow field order Skip stored properties that are initialized via init accessors and emit parameters/initializations in field order which allows us to cover more use-cases.
9ce73f5
to
34c8cf6
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
hborla
approved these changes
Jun 14, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
self
within init accessorsinitializes
oraccesses
attributes within init accessors@out
parameters are fully initialized before every terminator