void (@NotNull GrSwitchStatement switchStatement) { final GrCaseSection[] sections = switchStatement.getCaseSections(); List<PsiType> types = new ArrayList<>(sections.length); for (GrCaseSection section : sections) { for (GrExpression value : section.getExpressions()) { if (value != null) { final PsiType type = value.getType(); if (type != null) { types.add(type); } } } } final PsiType upperBoundNullable = TypesUtil.getLeastUpperBoundNullable(types, switchStatement.getManager()); if (upperBoundNullable == null) return; myResult = new TypeConstraint[]{SubtypeConstraint.create(upperBoundNullable)}; }