Skip to content

[5.1] Bring property wrappers up-to-date with the proposal under review #25484

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

DougGregor
Copy link
Member

Bring property 3wrappers up-to-date with the current proposal under review, which includes:

  • Add support for composing multiple property wrappers
  • Rename value to wrappedValue, but support the old name with a warning + Fix-It
  • Allow both initial-value and explicit initialization to work together
  • Make the $ property internal when wrappedValue is present

Should fix rdar://problem/51576815

When multiple property wrapper attributes are provided on a declaration,
compose them outside-in to form a composite property wrapper type. For
example,

  @A @b @C var foo = 17

will produce

  var $foo = A(initialValue: B(initialValue: C(initialValue: 17)))

and foo's getter/setter will access "foo.value.value.value".

(cherry picked from commit 82ed5e9)
…sition.

Rewrite findOriginalPropertyWrapperInitialValue() to cope with composition
of property wrappers, making it more robust in the process.

Should fix rdar://problem/51576815.

(cherry picked from commit e857852)
The latter name is far less likely to conflict. Maintain backward compatibility
by also accepting 'value' (with a warning).

(cherry picked from commit 99b40ba)
Allow both explicit initialization and initial values to work together, e.g.,

```
@clamping(min: 0, max: 255) var red: Int = 127
```

gets initialized as

```
Clamping(initialValue: 127, min: 0, max: 255)
```

(cherry picked from commit d35e1ea)
@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b450fea

@DougGregor DougGregor merged commit 5a124f1 into swiftlang:swift-5.1-branch Jun 17, 2019
@DougGregor DougGregor deleted the property-wrappers-5.1 branch June 17, 2019 18:38
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.

2 participants