Skip to content

[SILGen/DI] Add support for init accessor properties without setters #67107

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 8 commits into from
Jul 7, 2023

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jul 4, 2023

  • Allow mutation of init accessor properties without setters in initializer context when the base is self.
  • Factor out assign_or_init emission for init accessors into InitAccessorComponent
  • Add new InitAccessor write strategy for init accessor properties without setters
  • Adjust DI to detect and reject re-initialization if init accessor property doesn't have a setter (such properties behave like let properties).

xedin added 8 commits June 30, 2023 11:48
Factor our following logic:

- Applying setter to its base value
- `newValue` emission

This would be useful for init accessor emission as well.
… component

The logic is going to be shared when we start supporting init accessor
properties without `set`.
…cial write strategy

Such properties could be mutated only within initializer context
so they can employ a special "init accessor" strategy.
…ies without a setter

Implement "init accessor" component emission which is paired with
"init accessor" write strategy. Use `SILUndef` for a "setter" operand
of an "assign_or_init" instruction in cases when property with init
accessor doesn't have a setter. DI would detect re-initialization
attempts to produce diagnostics.
…erenced by `assign_or_init` instruction

This is going to be used by DI diagnostics.
…ty with a setter

Init accessor properties without setters behave just like `let` stored properties
and can only be initialized once.
@xedin xedin requested a review from jckarter July 4, 2023 07:57
@xedin xedin requested review from hborla and slavapestov as code owners July 4, 2023 07:57
@xedin
Copy link
Contributor Author

xedin commented Jul 4, 2023

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Jul 4, 2023

@swift-ci please test Windows platform

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Jul 5, 2023

@swift-ci please test Windows platform

@xedin
Copy link
Contributor Author

xedin commented Jul 7, 2023

@swift-ci please smoke test macOS platform

@xedin xedin merged commit 00729ad into swiftlang:main Jul 7, 2023
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.

3 participants