mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-highlighting] IDEA-313993 unreachable statement: false negative
GitOrigin-RevId: 396da7635b4bee1c921444c2b23f89f8c67e5895
This commit is contained in:
committed by
intellij-monorepo-bot
parent
84afde6440
commit
5e839de419
@@ -979,7 +979,7 @@ final class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
if (labelElementList != null) {
|
||||
for (PsiCaseLabelElement element : labelElementList.getElements()) {
|
||||
if (element instanceof PsiDefaultCaseLabelElement ||
|
||||
element instanceof PsiPattern && exprType != null && JavaPsiPatternUtil.isUnconditionalForType(element, exprType)) {
|
||||
exprType != null && JavaPsiPatternUtil.isUnconditionalForType(element, exprType)) {
|
||||
needToCreateDefault = true;
|
||||
break;
|
||||
}
|
||||
|
||||
+9
-1
@@ -1,5 +1,5 @@
|
||||
class C {
|
||||
void alwaysThrow(String s) {
|
||||
void alwaysThrow1(String s) {
|
||||
switch (s) {
|
||||
case "a" -> throw new IllegalArgumentException();
|
||||
default -> throw new IllegalStateException();
|
||||
@@ -7,6 +7,14 @@ class C {
|
||||
<error descr="Unreachable statement">System.out.println();</error>
|
||||
}
|
||||
|
||||
void alwaysThrow2(Integer i) {
|
||||
switch (i) {
|
||||
case Integer integer when true:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
<error descr="Unreachable statement">System.out.println(42);</error>
|
||||
}
|
||||
|
||||
void breakFromEndlessLoop() {
|
||||
EndlessLoop:
|
||||
for (;;) {
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@ package com.intellij.java.codeInsight.daemon
|
||||
|
||||
import com.intellij.JavaTestUtil
|
||||
import com.intellij.codeInspection.redundantCast.RedundantCastInspection
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
import com.intellij.testFramework.IdeaTestUtil
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
|
||||
class JavaSwitchExpressionsHighlightingTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
@@ -16,7 +18,7 @@ class JavaSwitchExpressionsHighlightingTest : LightJavaCodeInsightFixtureTestCas
|
||||
fun testSwitchNumericPromotion() = doTest()
|
||||
fun testSimpleInferenceCases() = doTest()
|
||||
fun testEnhancedSwitchDefinitelyAssigned() = doTest()
|
||||
fun testEnhancedSwitchUnreachable() = doTest()
|
||||
fun testEnhancedSwitchUnreachable() = IdeaTestUtil.withLevel(module, LanguageLevel.JDK_20_PREVIEW) { doTest() }
|
||||
fun testSwitchExpressionHasResult() = doTest()
|
||||
fun testYieldStatements() = doTest()
|
||||
fun testAssignToFinalInSwitchExpression() = doTest()
|
||||
|
||||
Reference in New Issue
Block a user