-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] Consolidate logic for whether a decl has a curried self or parameter list #25170
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] Consolidate logic for whether a decl has a curried self or parameter list #25170
Conversation
Use this function to replace various places where the logic is duplicated. In addition, isolate the logic where subscripts are treated as having curried self parameters to CalleeCandidateInfo, as their interface types don't have a curried self, but get curried with self by CalleeCandidateInfo. Ideally we'd fix this by having a subscript's interface type be curried with self, but given that most of this CSDiag logic should be going away, this may not be necessary.
Resolves SR-10795.
While it's currently not possible for `isDeclAsSpecializedAs` to compare decls that differ by having a curried self or having a parameter list, tweak the logic slightly so it could handle that case if it needed to. If one decl has a parameter list and the other doesn't, then just compare their self types. If one decl is curried and the other isn't, then add a curried self to the other and compare as normal.
Cool! Is it worth using this in |
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.
LGTM, thank you! I have left a small comment inline.
@slavapestov Good idea! I actually just noticed that we're duplicating the logic for how many curry levels a decl has in a bunch of places, so added |
@hamishknight Thanks! |
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 great
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
LLDB failure for OS X looks unrelated, also observed in https://ci.swift.org/job/swift-PR-osx/13822/. |
@swift-ci Please smoke test macOS |
Just found a 5.1 regression (SR-10843) related to this logic, so pushed a fix (I'll also open a 5.1 PR in a bit). Could you please re-run the CI when it comes back up? |
- Add a precondition on `doesDeclRefApplyCurriedSelf` to expect a member decl, and rename it to make the precondition explicit. - Don't assume that not having a base type means this isn't a member reference, as member references to static operators don't have base types. Resolves SR-10843.
277f9b2
to
356b3b4
Compare
This is a minimal cherry-pick of swiftlang#25170.
@swift-ci please test |
Build failed |
Build failed |
Linux failure appears to be unrelated |
@swift-ci please test Linux platform |
@swift-ci please smoke test and merge |
1 similar comment
@swift-ci please smoke test and merge |
Had to resolve a merge conflict with #25359, could you please try again? |
@swift-ci please smoke test and merge |
This PR adds
ValueDecl::hasCurriedSelf
andValueDecl::hasParameterList
that return whether a given declaration has a curried self parameter in its interface type and whether it has a parameter list, respectively. These members are then used in a couple of places where this logic is duplicated, as well as to fix a code completion bug.In addition, this PR tweaks
isDeclAsSpecializedAs
so that it could compare decls that differ by curry level if it needed to. This case doesn't currently come up though, so this should be NFC.Finally, this PR has a couple of straightforward NFC cleanups.
Resolves SR-10795.