private boolean switchBlockAssignsVariable(@NotNull PsiSwitchBlock switchBlock, @NotNull PsiVariable variable,
                                             int stamp, @NotNull Set<MethodSignature> checkedMethods) {
    final PsiExpression expression = switchBlock.getExpression();
    if (expressionAssignsVariable(expression, variable, stamp, checkedMethods)) {
      return true;
    }
    final PsiCodeBlock body = switchBlock.getBody();
    if (body == null) {
      return false;
    }
    final PsiStatement[] statements = body.getStatements();
    boolean containsDefault = false;
    boolean assigns = false;
    for (int i = 0; i < statements.length; i++) {
      final PsiStatement statement = statements[i];
      if (statement instanceof PsiSwitchLabelStatement labelStatement) {
        if (i == statements.length - 1) {
          return false;
        }
        if (labelStatement.isDefaultCase()) {
          containsDefault = true;
        }
        assigns = false;
      }
      else if (statement instanceof PsiBreakStatement) {
        if (((PsiBreakStatement)statement).getLabelIdentifier() != null || !assigns) {
          return false;
        }
      }
      else if (statement instanceof PsiYieldStatement) {
        PsiExpression valueExpression = ((PsiYieldStatement)statement).getExpression();
        if (!assigns) {
          if (expressionAssignsVariable(valueExpression, variable, stamp, checkedMethods)) {
            assigns = true;
          }
          else {
            return false;
          }
        }
      }
      else {
        assigns |= statementAssignsVariable(statement, variable, stamp, checkedMethods);
        if (i == statements.length - 1 && !assigns) {
          return false;
        }
      }
    }
    return assigns && (containsDefault || switchBlock instanceof PsiSwitchExpression);
  }
private boolean switchBlockAssignsVariable(@NotNull PsiSwitchBlock switchBlock, @NotNull PsiVariable variable,
                                             int stamp, @NotNull Set<MethodSignature> checkedMethods)