Skip to content

[AST/Sema] TypeWrappers: Extend implementation to support wrapped type #61501

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 11 commits into from
Oct 27, 2022

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Oct 8, 2022

  • Rename type wrapper init parameter to storage:
  • Rename type wrapper storage property to $storage
  • Introduce a Wrapped type parameter requirement
  • Adjust synthesized type wrapper init calls to pass the wrapped type
  • Add propertyKeyPath parameter to type wrapper subscripts
    subscripts are going to have both wrapped property and storage references - propertyKeyPath:storageKeyPath:
  • TypeWrappers: Use special subscript to manage storage of classes
    For wrapped classes allow to declare a special subscript that allows to pass down wrapped type instance.
  • Synthesize a body for memberwise initializer lazily to avoid forcing other synthesis
  • Synthesize an initializer that accepts a fully constructed wrapper type

Resolves: rdar://99884355

@xedin xedin requested a review from hborla October 8, 2022 00:23
@xedin
Copy link
Contributor Author

xedin commented Oct 11, 2022

@swift-ci please test

1 similar comment
@meg-gupta
Copy link
Contributor

@swift-ci please test

@xedin xedin force-pushed the type-wrappers-add-wrapped-type branch from a6e4203 to 534d0fb Compare October 19, 2022 21:26
@xedin
Copy link
Contributor Author

xedin commented Oct 21, 2022

@swift-ci please smoke test

@xedin xedin force-pushed the type-wrappers-add-wrapped-type branch from 534d0fb to 7d79941 Compare October 21, 2022 16:40
@xedin
Copy link
Contributor Author

xedin commented Oct 21, 2022

@swift-ci please smoke test

@xedin xedin force-pushed the type-wrappers-add-wrapped-type branch from 7d79941 to 6ff225d Compare October 21, 2022 17:57
@xedin
Copy link
Contributor Author

xedin commented Oct 21, 2022

@swift-ci please smoke test

xedin added 11 commits October 21, 2022 20:04
This parameter should be the first in the list of generic parameters.
`for: Wrapped.Type` parameter is added to a required initializer.
…per subscripts

The compiler is going to synthesize `\.<property-name>` as an argument
to `propertyKeyPath:` parameter which points to the wrapped property.
…lasses

New subscript allows to pass wrapped self instance down to the
type wrapper and is declared as follows:

```
subscript<...>(wrappedSelf <name>: Wrapped, propertyKeyPath: ..., storageKeyPath: ...)
```

The type-checker would use it to synthesize getter/setter accessors for
managed storage if wrapped type is a class.
Make sure that memberwise initializer body doesn't force
other synthesis by emitting it lazily.

Resolves: rdar://99884355
…torageWrapper: <Wrapper>)`

If there are no type wrapper ignored stored properties, the
compiler would synthesize a special public initializer that
allows to initialize a wrapped type by providing a fully
initialized wrapper instance.
Some of the key paths are printed inconsistently across
different platforms.
@xedin xedin force-pushed the type-wrappers-add-wrapped-type branch from 6ff225d to a82d8a5 Compare October 21, 2022 19:04
@xedin
Copy link
Contributor Author

xedin commented Oct 21, 2022

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Oct 21, 2022

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Oct 26, 2022

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Oct 26, 2022

@swift-ci please clean smoke test macOS platform

@xedin
Copy link
Contributor Author

xedin commented Oct 26, 2022

@swift-ci please clean smoke test Linux platform

@xedin xedin merged commit d8cfe03 into swiftlang:main Oct 27, 2022
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