-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Sema] Diagnose available attribute on wrapped and lazy properties #41112
[Sema] Diagnose available attribute on wrapped and lazy properties #41112
Conversation
@swift-ci please test source compatibility |
@swift-ci please smoke test |
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.
It might be worth quickly searching for more places to use the new predicate, but I'll let you decide if you want to do that.
if (hasStorage()) | ||
return true; | ||
auto *backing = getPropertyWrapperBackingProperty(); | ||
if (backing && backing->hasStorage()) |
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 believe the backing property is always necessarily stored
bool VarDecl::hasStorageOrWrapsStorage() const { | ||
if (hasStorage()) | ||
return true; | ||
auto *backing = getPropertyWrapperBackingProperty(); |
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.
Can you also add a check for getAttributes().hasAttribute<LazyAttr>()
?
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 assume this suggestion is to avoid going into the request evaluator when it's not necessary. Should we instead add this check inside the VarDecl::getPropertyWrapper*
methods to avoid doing it at all of the call sites?
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.
Sorry, a formatting error there -- I meant to write getAttributes().hasAttribute<LazyAttr>()
-- we need the same check for lazy properties as well.
I'm assuming the short-circuiting check you're thinking of is for CustomAttr
. I remember this was worthwhile at one point because we weren't caching the results of some of these requests, but I'm not sure anymore.
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.
Thanks, I've added the check for the lazy
attribute as well.
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.
Whoops, yes, I thought you were talking about checking for custom attributes. Sorry!
I did scrutinize many of the uses of |
1c788f5
to
02fa6f3
Compare
swiftlang/swift-package-manager#4075 @swift-ci Please test source compatibility |
02fa6f3
to
ec10a7b
Compare
swiftlang/swift-package-manager#4075 @swift-ci Please test source compatibility |
@swift-ci Please test source compatibility |
@swift-ci please smoke test |
…ions that have attached property wrappers. Availability is not supported on stored properties, and properties with property wrappers are stored properties with a layer of indirection. Also, add the same missing diagnostic for `lazy` vars. Resolves rdar://82713248
ec10a7b
to
093b8d3
Compare
Had to fix fallout in additional test but it looks like source compatibility passed: https://ci.swift.org/job/swift-PR-source-compat-suite/5809/ |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@slavapestov @hborla Now that we're correctly reflecting the fact that |
@swift-ci please smoke test |
Gem dependencies have been updated as well. The project has been updated for Xcode 14, including recommended project file updates and to resolve [this new diagnostic in the Swift 5.7 compiler](swiftlang/swift#41112).
Emit an error when
@available
is used on property declarations that either have attached property wrappers or arelazy
since availability is not supported on properties with backing storage.Resolves rdar://82713248