Skip to content

Conversation

DougGregor
Copy link
Member

Property wrappers are allowed to infer the type of a variable, but this
only worked when the property wrapper was provided with an explicit
initialization, e.g.,

@WrapsAnInt() var x   // infers type Int from WrapsAnInt.wrappedValue

However, when default initialization is supported by the property wrapper,
dropping the parentheses would produce an error about the missing type
annotation

@WrapsAnInt var x

Make this second case behave like the first, so that default initialization
works consistently with the explicitly-specified version.
Fixes rdar://problem/59471019.

Property wrappers are allowed to infer the type of a variable, but this
only worked when the property wrapper was provided with an explicit
initialization, e.g.,

    @WrapsAnInt() var x   // infers type Int from WrapsAnInt.wrappedValue

However, when default initialization is supported by the property wrapper,
dropping the parentheses would produce an error about the missing type
annotation

    @WrapsAnInt var x

Make this second case behave like the first, so that default initialization
works consistently with the explicitly-specified version.
Fixes rdar://problem/59471019.
@DougGregor DougGregor requested a review from hborla March 26, 2020 20:54
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

DougGregor commented Mar 26, 2020

The Release source compatibility build failed with:

xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist

…ropriate

wrappedValue is the new name, and we only support initialValue for backward
compatibility with earlier revisions of the property wrappers proposal.
@xymus
Copy link
Contributor

xymus commented Mar 27, 2020

Let's see if the source compat bots are in a better shape now.

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

Source compatibility bots were fine; I've pulled in the cleanup @hborla suggested and will land with that.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 85762c3 into swiftlang:master Mar 27, 2020
@DougGregor DougGregor deleted the property-wrapper-default-init-infer-type branch March 27, 2020 20:46
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