private static void replaceWithCast(@NotNull PsiPatternVariable variable, @Nullable List<PsiReferenceExpression> references) {
      if (references == null || references.isEmpty()) {
        return;
      }

      String text = JavaPsiPatternUtil.getEffectiveInitializerText(variable);
      if (text == null) {
        return;
      }

      references.forEach(reference -> {
        PsiReplacementUtil.replaceExpression(reference, text, new CommentTracker());
      });
    }
private static void replaceWithCast(@NotNull PsiPatternVariable variable, @Nullable List<PsiReferenceExpression> references)