void (@NotNull PsiSwitchExpression switchExpression, @NotNull Consumer<? super HighlightInfo.Builder> errorSink) { if (!PsiPolyExpressionUtil.isPolyExpression(switchExpression)) { return; } PsiType switchExpressionType = switchExpression.getType(); if (switchExpressionType != null) { for (PsiExpression expression : PsiUtil.getSwitchResultExpressions(switchExpression)) { PsiType expressionType = expression.getType(); if (expressionType != null && !TypeConversionUtil.areTypesAssignmentCompatible(switchExpressionType, expression)) { String text = JavaErrorBundle .message("bad.type.in.switch.expression", expressionType.getCanonicalText(), switchExpressionType.getCanonicalText()); HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(text); registerChangeTypeFix(info, switchExpression, expressionType); errorSink.accept(info); } } if (PsiTypes.voidType().equals(switchExpressionType)) { String text = JavaErrorBundle.message("switch.expression.cannot.be.void"); HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(switchExpression.getFirstChild()).descriptionAndTooltip(text); errorSink.accept(info); } } }