PsiType (@NotNull PsiExpression condition, @NotNull PsiExpression thenExpression, @NotNull PsiExpression elseExpression) { final PsiType thenType = thenExpression.getType(); final PsiType elseType = elseExpression.getType(); if (thenType == null || elseType == null) return null; if (thenType.isAssignableFrom(elseType)) return thenType; if (elseType.isAssignableFrom(thenType)) return elseType; if (!(thenType instanceof PsiClassType) || !(elseType instanceof PsiClassType)) return null; if (TypeConversionUtil.isPrimitiveWrapper(thenType) || TypeConversionUtil.isPrimitiveWrapper(elseType)) return null; return GenericsUtil.getLeastUpperBound(thenType, elseType, condition.getManager()); }