Skip to content

[Property Wrappers] Adjust composed property wrapper constraint generation #31876

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

hborla
Copy link
Member

@hborla hborla commented May 19, 2020

When generating constraints for composed property wrappers, equate the former wrappedValue type with the current wrapper type rather than generating value member constraints.

Without connecting a wrappedValue type with the subsequent wrapper type, the constraint system couldn't infer types in some cases where the wrappedValue argument to the outermost wrapper init is defaulted.

This change also makes another step toward unifying how property wrapper backing types are computed. The code in generateWrappedPropertyTypeConstraints is now very similar to the computation of the property wrapper backing type in the absence of an initial value/default initialization in PropertyWrapperBackingPropertyTypeRequest. I intend to remove the duplication in a follow-up refactoring, which will also improve some diagnostics when the wrapped property has an incompatible type.

Resolves: rdar://problem/59740181
Resolves: SR-12250

@hborla hborla requested a review from DougGregor May 19, 2020 01:10
@hborla
Copy link
Member Author

hborla commented May 19, 2020

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented May 19, 2020

@swift-ci please test source compatibility

1 similar comment
@hborla
Copy link
Member Author

hborla commented May 19, 2020

@swift-ci please test source compatibility

@hborla
Copy link
Member Author

hborla commented Jun 16, 2020

@swift-ci please smoke test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a lot cleaner, thank you!

wrappers, equate the former wrappedValue type with the current wrapper
type rather than generating value member constraints.
@hborla hborla force-pushed the property-wrapper-composition-inference branch from 959e635 to 392a263 Compare June 16, 2020 20:59
@hborla
Copy link
Member Author

hborla commented Jun 16, 2020

@swift-ci please smoke test

@hborla hborla merged commit 28ab5ce into swiftlang:master Jun 16, 2020
@hborla hborla deleted the property-wrapper-composition-inference branch June 16, 2020 23:50
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