Skip to content
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

[WIP] Property delegates #23440

Closed
wants to merge 46 commits into from

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 20, 2019

This is the implementation of the Property Delegates feature currently being pitched on the forums. Or, you can read the proposal.

The implementation has a few notable limitations:

  • libSyntax/SwiftSyntax support is missing
  • Backing storage properties for locally-scoped properties with delegates can't be found by name lookup

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

3 similar comments
@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility release

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility release

@DougGregor DougGregor added the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Mar 22, 2019
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

apple/swift-lldb#1402 should fix the LLDB compiler error

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please build toolchain

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please build toolchain

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please build toolchain

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - c4fcb6a4c45fd9c1c7dd0eba5bdbda8b585152a3

Install command
tar zxf swift-PR-23440-175-ubuntu16.04.tar.gz
More info

@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - c4fcb6a4c45fd9c1c7dd0eba5bdbda8b585152a3

Install command
tar -zxf swift-PR-23440-230-osx.tar.gz --directory ~/

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please build toolchain

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please build toolchain

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - e0b2d40ea7fe2a536d1cbdada5cb27490b432e68

Install command
tar zxf swift-PR-23440-177-ubuntu16.04.tar.gz
More info

@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - e0b2d40ea7fe2a536d1cbdada5cb27490b432e68

Install command
tar -zxf swift-PR-23440-232-osx.tar.gz --directory ~/

…tializer.

SE-0242 was merged, and I haven't yet figured out how it interacts with
property delegates. Disabled default arguments in the memberwise
initializer for properties that have delegates until I have a design +
implementation.
If a property delegate type's 'value' property has a private setter, don't
create a setter for a property that uses that delegate type.
…alValue:)' .

The 'value' property and 'init(initialValue:)' initializer cannot have
more restrictive access than the property delegate itself. Diagnose
this.
Rather than hardcoding the access patterns for the backing property of
a property with a delegate, extend the “target implementation” notion
used to abstract property access for code synthesis to understand the
delegate pattern. This collapses the getter/setter implementation into
the “trivial” cases uses the delegate access pattern.

As a bonus, we get @_transparent when it makes sense.
A property with a delegate can provide didSet/willSet. Synthesize a setter
that calls didSet/willSet appropriately for such properties.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please build toolchain

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - 32430ec

Install command
tar zxf swift-PR-23440-185-ubuntu16.04.tar.gz
More info

The implementation to support delegates on local properties has grown
past the point where I feel comfortable committing it now, so an
delegates on local properties for now.
…egates.

Parse custom attributes with the grammer

```
  '@' type-identifier expr-paren?
```

When the type-identifier refers to a nominal type with the
@propertyDelegate attribute, treat this as being equivalent to

```swift
  by type-identifier expr-paren?
```
@DougGregor
Copy link
Member Author

@swift-ci please build toolchain

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please build toolchain

@DougGregor
Copy link
Member Author

This was obsoleted by the "custom attributes" approach

@DougGregor DougGregor closed this May 4, 2019
@AnthonyLatsis AnthonyLatsis removed the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Apr 18, 2023
@AnthonyLatsis
Copy link
Collaborator

Proposal: SE-0030.

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