-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc #33320
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
Conversation
Unlike \keypath expressions, only the property components of #keypath expressions were being resolved, so index wouldn't pick up references for their qualifying types. Also fixes a code completion bug where it was reporting members from the Swift rather than ObjC side of bridged types. Resolves rdar://problem/61573935
@swift-ci please test |
@swift-ci please test source compatibility |
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.
Makes sense to me.
@@ -4657,13 +4657,24 @@ ERROR(availability_decl_unavailable, none, | |||
"%select{ in %3|}2%select{|: %4}4", | |||
(unsigned, DeclName, bool, StringRef, StringRef)) | |||
|
|||
WARNING(availability_decl_unavailable_warn, none, | |||
"%select{getter for |setter for |}0%1 is unavailable" |
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.
Please add both of these new diagnostics to localization/diagnostics/en.yaml
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.
Oh neat! Will do.
Build failed |
lib/Sema/TypeCheckAvailability.cpp
Outdated
@@ -2508,7 +2523,8 @@ class AvailabilityWalker : public ASTWalker { | |||
auto *decl = component.getDeclRef().getDecl(); | |||
auto loc = component.getLoc(); | |||
SourceRange range(loc, loc); | |||
diagAvailability(decl, range, nullptr); | |||
diagAvailability(decl, range, nullptr, | |||
DeclAvailabilityFlag::ForObjCKeyPath); |
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.
Oops, this needs to check it's actually an ObjC rather than Swift keypath first. Fixing...
Build failed |
… keypaths to prevent source breakage. The change to resolve ObjC #keyPath expression components caused some source breakage as they are now being checked for availability issues. This change updates availability checking to demote error diagnostics to warnings within #keyPath expressions. There were cases in the source compat suite where unavailble properites were used in #keyPath expressions, but they caused no issues at runtime because the properties' ObjC runtime name was still correct (e.g. the same as its renamed-to property in Swift).
94e02b1
to
38e2bd9
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
Build failed |
This is a re-do of #33245 to account for source breakage.
Unlike
\keypath
expressions, the components of#keyPath()
expressions weren't being resolved, so the index wouldn't pick up references for their qualifying types/properties. Semantic highlighting, cursor info, etc wouldn't work on them either. My fix for this part is largely based on @rockbruno's closed PR here: #20020 (thanks @rockbruno!)The change to resolve ObjC
#keyPath
expression components caused some source breakage as they are now being checked for availability issues. To avoid that this change also updates availability checking to demote error diagnostics to warnings within#keyPath
expressions. There were cases in the source compat suite where unavailable properties were used in#keyPath
expressions, but worked correctly at runtime because the properties' ObjC runtime name was still correct (in this case the same as its renamed-to property in Swift).Also fixes a code completion bug where it was reporting members from the Swift rather than ObjC side of bridged types (
#keyPath(MyClass.someString.count)
is invalid, butkeyPath(MyClass.someString.length)
is valid).Resolves rdar://problem/61573935