Skip to content

[5.3][Property Wrappers] For now, don't allow wrappedValue and projectedValue to have dynamic Self type. #31427

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 Apr 30, 2020

Cherry-picked from #31344 and it's follow-up #31443


Currently, when wrappedValue or projectedValue have dynamic Self type, the synthesized properties when using the wrapper will also get a dynamic Self type, but in a new context. This bug could manifest as really misleading diagnostics, or a crash. For now, we will disallow this, but we can re-visit implementing correct support for this in the future.

Resolves: rdar://problem/53258469

@hborla hborla requested a review from DougGregor April 30, 2020 00:18
@hborla
Copy link
Member Author

hborla commented Apr 30, 2020

@swift-ci please test

@hborla hborla added the r5.3 label Apr 30, 2020
@@ -2862,7 +2862,7 @@ void AttributeChecker::visitCustomAttr(CustomAttr *attr) {

// If the nominal type is a property wrapper type, we can be delegating
// through a property.
if (nominal->getPropertyWrapperTypeInfo()) {
if (nominal->getAttrs().hasAttribute<PropertyWrapperAttr>()) {
Copy link
Contributor

@slavapestov slavapestov Apr 30, 2020

Choose a reason for hiding this comment

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

What does this change do? I’m not objecting, just curious

Copy link
Member Author

Choose a reason for hiding this comment

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

This change only suppresses the cannot be used as attribute diagnostic in the case where the nominal type for the custom attribute type is declared as @propertyWrapper but there's some other error, such as the type not having a non-static wrappedValue property

@hborla hborla changed the title [Property Wrappers] For now, don't allow wrappedValue and projectedValue to have dynamic Self type. [5.3][Property Wrappers] For now, don't allow wrappedValue and projectedValue to have dynamic Self type. Apr 30, 2020
wrappedValue/projectedValue to also cover optional.
@hborla
Copy link
Member Author

hborla commented Apr 30, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 93098aa

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 93098aa

@hborla hborla merged commit bf72a8e into swiftlang:release/5.3 May 1, 2020
@hborla hborla deleted the 5.3-property-wrapper-invalid-dynamic-self branch May 1, 2020 19:01
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants