-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Refactoring] Use known alternative in async refactoring if one exists #38689
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
@swift-ci please test |
Build failed |
Failing test was disabled in another PR that's now merged @swift-ci please test macOS platform |
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!
// MULTIPLEHANDLERS: func multipleHandlers() async { | ||
// MULTIPLEHANDLERS-NEXT: let str2 = await multiHandlers2(newArg: "foo", newHandler: { str1 in | ||
// MULTIPLEHANDLERS-NEXT: print(str1) | ||
// MULTIPLEHANDLERS-NEXT: }) |
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.
Nice!
703411c
to
9f26b23
Compare
@etcwilde I forgot to add tests for renaming to a getter in the attribute tests. 8f4d272 fixes the @hamishknight there's now some code to handle the accessor and I changed SemaAnnotator to walk the |
@swift-ci please test |
Build failed |
Build failed |
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.
Accessor and curry thunk changes look good to me!
lib/IDE/Refactoring.cpp
Outdated
if (auto *Accessor = dyn_cast<AccessorDecl>(HandlerDesc.Alternative)) | ||
Name = Accessor->getStorage()->getBaseIdentifier(); | ||
else | ||
Name = HandlerDesc.Alternative->getBaseIdentifier(); |
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.
Just occurred to me that getBaseIdentifier
would hit an assertion if this a decl with a special name such as init
, and I believe we support marking those async.
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.
init
can definitely be marked async, but it wouldn't make sense as a completion handler function since it inherently returns a value (and thus should never be an alternative).
Regardless, it's probably better to check and fallback anyway - only adds a line or two.
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.
Ah right yeah, sounds good 👍
9f26b23
to
0c9651e
Compare
Moved the SourceEntityWalker changes to #38712. Tests will fail until that's in, so I won't bother running them yet. |
A lookup on the name provided by `renamed` in `@available` returns the VarDecl. If the name specified a getter or setter, make sure to grab the corresponding accessor when comparing candidates. We currently ignore the basename and parameters specified in the name for accessors. Checking them would only cause a getter/setter not to match, there can never be a conflict. Since this is a best effort match anyway, this seems fine.
Update the async refactorings to use the name from the async alternative if one is known, rather than always assuming the name matches the synchronous function. Note that this could also be used to determine whether results remain optional or not, but that has been left for a future patch. Resolves rdar://80612521
0c9651e
to
f6a8dab
Compare
@swift-ci please test |
Update the async refactorings to use the name from the async alternative
if one is known, rather than always assuming the name matches the
synchronous function.
Note that this could also be used to determine whether results remain
optional or not, but that has been left for a future patch.
Resolves rdar://80612521