Skip to content

[Sema/SIL] InitAccessors: Support default initialization of init accessor properties #67294

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

xedin
Copy link
Contributor

@xedin xedin commented Jul 13, 2023

  • Emit default initialization of init accessor properties in user-defined initializers
  • Make sure that init accessor properties take over default initialization of all stored properties listed in "initializes"
  • Teach default class initializer emission (init()) about init accessors (even if a stored property doesn't have an initializer expression, the compiler needs to check whether init accessor property that handles it does).
  • Fix a bug in DI which used incorrect field indexes for subclasses.

Resolves: rdar://112417250

@xedin xedin requested a review from jckarter July 13, 2023 23:00
@xedin xedin requested review from hborla and slavapestov as code owners July 13, 2023 23:01
@xedin
Copy link
Contributor Author

xedin commented Jul 14, 2023

@swift-ci please test

@xedin xedin force-pushed the default-init-via-accessor-in-custom-initializers branch from d9cbc79 to 1593a14 Compare July 14, 2023 20:43
@xedin
Copy link
Contributor Author

xedin commented Jul 14, 2023

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Jul 14, 2023

@swift-ci please test Windows platform

xedin added 10 commits July 18, 2023 17:19
…SILGenFunction

This is a preliminary step towards enabling default initialization of
init accessor properties in user-defined initializers because this logic
would have to be shared by multiple places during SILGen.
Instead of taking a setter type, let's switch over to a more general
`AccessorKind` which allows us to cover init accessors and simplify
`emitApplySetterToBase`.
…eparate method

New method is going to be used to emit default value initializations
for user-defined constructors.
…xpressions

Similar to regular stored properties emit initialization expressions
for properties with init accessors at constructor's prolog.
…nitialization of stored properties

Default expression associated with an init accessor property
should always subsume that of any property listed in "initializes".
…about init accessors

If stored property is covered by one or more init accessor property,
it's default initializable when at least one of the init accessor
properties has default value.
…inBorrowOperation returns back original value

Calling `emitBeginBorrowOperation` on something which is `load_borrow`
for example with guaranteed ownership doesn't produce `begin_borrow`
instruction, so we need to be careful not to emit mismatched `end_borrow`
in such cases.
… with DI data structures

DI cares only about stored fields of the current type but `SILModule::getFieldIndex`
goes through all of the supertypes as well.
…ass properties

`super.init()` should fully initialize "super" which means that
such properties are mutated via a setter.
@xedin xedin force-pushed the default-init-via-accessor-in-custom-initializers branch from 1593a14 to ff19286 Compare July 19, 2023 07:11
@xedin
Copy link
Contributor Author

xedin commented Jul 19, 2023

@swift-ci please test

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