boolean (@NotNull PsiCaseLabelElement label, @NotNull PsiSwitchBlock switchBlock) { if (!(label instanceof PsiPattern)) return true; PsiExpression selector = switchBlock.getExpression(); if (selector == null) return false; PsiType selectorType = selector.getType(); if (selectorType == null) return false; if (!JavaPsiPatternUtil.isUnconditionalForType(label, selectorType)) return true; int branchCount = SwitchUtils.calculateBranchCount(switchBlock); // it's a compilation error if switch contains both default and an unconditional pattern, so no additional suggestion is needed return branchCount > 1; }