mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] IDEA-356945 'insert default branch' suggests uncompilable code
GitOrigin-RevId: 44f277da31601775e3ce75021155bf7c37a6311c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8e4ac5ef4b
commit
4a9f1b4fee
+1
@@ -951,6 +951,7 @@ public class PatternsInSwitchBlockHighlightingModel extends SwitchBlockHighlight
|
||||
AtomicBoolean reported = new AtomicBoolean();
|
||||
if (switchModel instanceof PatternsInSwitchBlockHighlightingModel patternsInSwitchModel) {
|
||||
if (findUnconditionalPatternForType(labelElements, switchModel.mySelectorType) != null) return COMPLETE_WITH_UNCONDITIONAL;
|
||||
if (switchModel.getSwitchSelectorKind() == SelectorKind.BOOLEAN && hasTrueAndFalse(labelElements)) return COMPLETE_WITH_UNCONDITIONAL;
|
||||
if (!needToCheckCompleteness && !isEnumSelector) return INCOMPLETE;
|
||||
//it is necessary,
|
||||
// because deconstruction patterns don't cover cases when some of their components are null and deconstructionPattern too
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.siyeh.igtest.controlflow.switch_statements_without_default;
|
||||
|
||||
class TrueFalsePatterns {
|
||||
static void foo(Boolean b) {
|
||||
switch (b) {
|
||||
case true -> System.out.println("It's true");
|
||||
case false -> System.out.println("It's false");
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -24,7 +24,13 @@ public class SwitchStatementsWithPatternsInspectionTest extends LightJavaInspect
|
||||
myInspection.m_ignoreFullyCoveredEnums = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testTrueFalsePatterns() {
|
||||
String name = getTestName(false);
|
||||
myFixture.configureByFile(name + ".java");
|
||||
myFixture.testHighlighting(true, true, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
@@ -33,6 +39,6 @@ public class SwitchStatementsWithPatternsInspectionTest extends LightJavaInspect
|
||||
|
||||
@Override
|
||||
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_21;
|
||||
return JAVA_23;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user