private static @NotNull List<ExpectedTypeInfo> collectFromLabels(@NotNull PsiSwitchBlock statement) {

      List<PsiType> labeledExpressionTypes = new ArrayList<>();
      List<PsiType> labeledPatternsTypes = new ArrayList<>();

      List<ExpectedTypeInfo> result = new ArrayList<>();

      boolean mustBeReference = false;
      PsiCodeBlock body = statement.getBody();
      if (body == null) {
        return result;
      }
      for (PsiStatement psiStatement : body.getStatements()) {
        if (psiStatement instanceof PsiSwitchLabelStatementBase labelStatement) {
          if (labelStatement.isDefaultCase()) {
            continue;
          }
          PsiCaseLabelElementList labelElementList = labelStatement.getCaseLabelElementList();
          if (labelElementList == null) {
            continue;
          }
          for (PsiCaseLabelElement caseLabelElement : labelElementList.getElements()) {
            if (caseLabelElement instanceof PsiExpression expression) {
              PsiType type = expression.getType();
              if (type == null) {
                continue;
              }
              if (type == PsiTypes.nullType()) {
                mustBeReference = true;
                continue;
              }
              labeledExpressionTypes.add(type);
            }
            if (caseLabelElement instanceof PsiPattern pattern) {
              PsiType type = JavaPsiPatternUtil.getPatternType(pattern);
              if (type == null) {
                continue;
              }
              labeledPatternsTypes.add(type);
            }
          }
        }
      }
      result.addAll(findExpectedTypesForExpressions(labeledExpressionTypes, mustBeReference, statement));
      result.addAll(findExpectedTypesForPatterns(labeledPatternsTypes, statement));
      return result;
    }
private static @NotNull List<ExpectedTypeInfo> collectFromLabels(@NotNull PsiSwitchBlock statement)