-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Property Wrappers] Fix availability inference of synthesized property wrapper setters #36711
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
[Property Wrappers] Fix availability inference of synthesized property wrapper setters #36711
Conversation
…ed value setter with the availability of the enclosing scope when inferring the availability of the synthesized setters for an applied property wrapper.
@swift-ci please smoke test |
lib/Sema/TypeCheckStorage.cpp
Outdated
@@ -1968,6 +1968,17 @@ static AccessorDecl *createSetterPrototype(AbstractStorageDecl *storage, | |||
|
|||
// Copy availability from the accessor we'll synthesize the setter from. | |||
SmallVector<Decl *, 2> asAvailableAs; | |||
|
|||
auto addEnclosingScopeAvailability = [&]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks similar to the code in configureInheritedDesignatedInitAttributes(). Maybe applyInferredAvailableAttrs() should take an optional Decl in addition to the array of AvailableAttrs, and walk over the Decls parents if its not null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it might be better to extract a getInnermostAvailabilityOfDecl() or something and use it in both places, or perhaps its not worth it at all...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be useful to extract this code somewhere, especially if the availability inference doesn't work for _modify
(which I think it doesn't), so it'll need to be used there as well
lib/Sema/TypeCheckStorage.cpp
Outdated
@@ -1978,6 +1989,7 @@ static AccessorDecl *createSetterPrototype(AbstractStorageDecl *storage, | |||
if (info.valueVar) { | |||
if (auto setter = info.valueVar->getOpaqueAccessor(AccessorKind::Set)) { | |||
asAvailableAs.push_back(setter); | |||
addEnclosingScopeAvailability(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you don't have to worry about this with the getter because a property wrapper's getter cannot be less available than the property wrapper type, but if the wrapper defines a _modify
as well?
…accessor of a wrapped property.
@swift-ci please test source compatibility |
@swift-ci please smoke test |
@swift-ci please test Windows platform |
Intersect the availability of the wrapped/projected value setter with the availability of the enclosing scope when inferring the availability of the synthesized setter for an applied property wrapper.
Resolves: rdar://71872385