Skip to content
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

Extract to local variable quick assist should not be offered when there is no change #1176

Closed
jjohnstn opened this issue Feb 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jjohnstn
Copy link
Contributor

jjohnstn commented Feb 7, 2024

In the following example:

private class UtilClass {
    public static int combineHashCodes(int a, int b) {
        return a + b;
    }
}
@Override
public int hashCode() {
    int k = this.parent == null ? super.hashCode() :
    UtilClass.combineHashCodes(getElementName().hashCode(), this.parent.hashCode());
    return k;
}

Trying to extract the UtilClass.combineHashCodes() call in the conditional should not offer to put this into a local variable because the ExtractTempRefactoring code will not know whether moving the call in front of the conditional test will cause a logic change or possibly and exception to occur. Currently, the assist is offered any way and clicking on it damages the code by removing the method call from the conditional.

@jjohnstn
Copy link
Contributor Author

jjohnstn commented Feb 9, 2024

Fixed by #1177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant