mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
[java-inspections] UseHashCodeMethodInspection: check for side-effects (IDEA-338114)
GitOrigin-RevId: cf54ae1e7c99e0ddff88bf8a6bf951b36f8b89b7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
96cc92c0ce
commit
3fad9d4a33
@@ -90,8 +90,8 @@ public final class UseHashCodeMethodInspection extends AbstractBaseJavaLocalInsp
|
||||
if (shiftingExpression.getOperationSign().getTokenType() != JavaTokenType.GTGTGT) return false;
|
||||
|
||||
PsiExpression leftSubOperand = shiftingExpression.getLOperand();
|
||||
return EquivalenceChecker.getCanonicalPsiEquivalence()
|
||||
.expressionsAreEquivalent(leftOperand, leftSubOperand) &&
|
||||
return EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(leftOperand, leftSubOperand) &&
|
||||
!SideEffectChecker.mayHaveSideEffects(leftOperand) &&
|
||||
Objects.equals(32, ExpressionUtils.computeConstantExpression(shiftingExpression.getROperand()));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace with 'Long.hashCode()'" "false"
|
||||
public class Test {
|
||||
long var = 1234567890123456789L;
|
||||
|
||||
public void testMethod() {
|
||||
int result = (int<caret>)((var++) ^ ((var++) >>> /*shift amount*/ 32));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user