-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Refactoring] Fix an issue where refactoring misses to refactor references after prefix operators #58613
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
[Refactoring] Fix an issue where refactoring misses to refactor references after prefix operators #58613
Conversation
@swift-ci Please smoke test |
This is syntactic rename, maybe @benlangmuir or @nathawes may remember. |
If the tests pass, I believe this case should be fine to remove. It was for renaming enum cases with labels, and was covered by syntactic-rename.swift test with the input from enum_case.in.json. From what I can tell, that test is still passing. |
Removing the branch seems fine if the enum case is still passing but I was expecting LabelRangeType to be None in this case so it wouldn't take that branch anyway. Assuming I'm remembering correctly, it might be worth looking into why NameMatcher is giving the reference to foo on line 2 of the new test a non-None LabelRangeType in case that's causing other problems too. |
I did some more debugging and the following is happening: We walk the argument list of AFAICT there’s no need to call I kept the removal of the special handling for enum cases with labels in this PR as well because it seems like some good cleanup on its own accord. If anyone has feelings and wants to keep the case, I can add it back in. |
32ca13c
to
481098b
Compare
@swift-ci Please smoke test |
lib/IDE/SwiftSourceDocInfo.cpp
Outdated
tryResolve(Parent, ArgList->getStartLoc(), LabelRangeType::CallArg, | ||
Labels.first, Labels.second); |
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 this was trying to preserve the original logic for parens and tuples:
78d8d09#diff-5fb3c14eb2d2fd312df17ef5b7e60ab238f2ef17a9944c3feede1373bc64d391L385-L389
Though it seems that would have previously been skipped for implicit argument lists, which therefore would have been skipped for operator argument lists.
It seems like it was originally added in #30964 to handle callAsFunction
cases, is this still needed @nathawes?
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.
Yeah I think we might need to keep it– indexing uses the open paren as the base location of the call for callAsFunction (since there's no function name).
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, we should probably restore the !isImplicit
check in that case
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.
Good idea 👍
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 we add a test for that case?
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’s already covered by https://github.com/apple/swift/blob/main/test/refactoring/SyntacticRename/call-as-function.swift and a few others (which did fail before the latest commit).
481098b
to
ede8f36
Compare
@swift-ci Please smoke test |
…ences after prefix operators The removed `else if` branch caused the argument to the `-` operator to be be reported as `Mismatch`. I couldn’t figure out what that branch was for, so I removed it. rdar://91588948
ede8f36
to
6d2582f
Compare
@swift-ci Please smoke test |
The removed
else if
branch caused the argument to the-
operator to be be reported asMismatch
. I couldn’t figure out what that branch was for, so I removed it.@akyrtzi If you have any memory what the removed
else if
branch was for, I would be interested to hear it. But I assume that you don’t remember since it’s been nearly 5 years since you upstreamed local renaming.rdar://91588948