boolean (@Nullable PsiExpression expression, @NotNull PsiExpression constantExpression, @NotNull PsiElement body) { final PsiType constantType = constantExpression.getType(); if (constantType == null) { return false; } if (PsiTypes.doubleType().equals(constantType)) { final Object result = ExpressionUtils.computeConstantExpression(constantExpression, false); if (Double.valueOf(0.0).equals(result) || Double.valueOf(-0.0).equals(result)) { return false; } } expression = PsiUtil.skipParenthesizedExprDown(expression); if (!(expression instanceof PsiReferenceExpression referenceExpression)) { return false; } final PsiElement target = referenceExpression.resolve(); if (!(target instanceof PsiVariable variable)) { return false; } if (target instanceof PsiField) { return false; } final VariableReadVisitor visitor = new VariableReadVisitor(variable); body.accept(visitor); if (!visitor.isRead()) { return false; } final PsiReferenceExpression reference = visitor.getReference(); final PsiType referenceType = reference.getType(); if (referenceType == null) { return false; } if (!referenceType.isAssignableFrom(constantType)) { return false; } registerError(reference, constantExpression); return true; }