@Override
      public void visitPatternVariable(@NotNull PsiPatternVariable variable) {
        super.visitPatternVariable(variable);
        if (!REPORT_PATTERN_VARIABLES) return;
        if (PsiTreeUtil.getParentOfType(variable, PsiClass.class) != PsiTreeUtil.getParentOfType(body, PsiClass.class)) {
          return;
        }
        PsiElement context = PsiTreeUtil.getParentOfType(variable,
                                                         PsiInstanceOfExpression.class,
                                                         PsiSwitchLabelStatementBase.class,
                                                         PsiForeachPatternStatement.class,
                                                         PsiForeachStatement.class);
        int from;
        int end;
        if (context instanceof PsiInstanceOfExpression instanceOf) {
          from = flow.getEndOffset(instanceOf);
          end = flow.getEndOffset(body);
        }
        else if (context instanceof PsiSwitchLabelStatementBase label) {
          PsiExpression guardExpression = label.getGuardExpression();
          if (guardExpression != null) {
            from = flow.getStartOffset(guardExpression);
          }
          else {
            from = flow.getEndOffset(label);
          }
          end = flow.getEndOffset(body);
        }
        else if (context instanceof PsiForeachPatternStatement forEach) {
          PsiStatement body = forEach.getBody();
          if (body == null) return;
          from = flow.getStartOffset(body);
          end = flow.getEndOffset(body);
        }
        else {
          return;
        }
        from = MathUtil.clamp(from, 0, flow.getInstructions().size());
        end = MathUtil.clamp(end, from, flow.getInstructions().size());
        if (!ControlFlowUtil.getWrittenVariables(flow, from, end, false).contains(variable)) {
          writtenVariables.remove(variable);
          result.add(variable);
        }
      }
@Override
      public void visitPatternVariable(@NotNull PsiPatternVariable variable)