mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
[java-highlighting] IDEA-324314 Enums must be qualified with switch with compatible types
GitOrigin-RevId: db218b31e81d767fff0c341a00593983522564b1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4f951e7be9
commit
07a6f3f57a
@@ -0,0 +1,49 @@
|
||||
import java.util.Optional;
|
||||
|
||||
class Main {
|
||||
interface IT {
|
||||
}
|
||||
|
||||
sealed interface IT2 {
|
||||
}
|
||||
|
||||
enum T implements IT, IT2 {
|
||||
A, B, C;
|
||||
|
||||
public void test2(IT2 t2) {
|
||||
switch (t2) {
|
||||
case T.A -> System.out.println("1");
|
||||
case B -> System.out.println("2");
|
||||
case T.C -> System.out.println("3");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public void test0(IT2 t2) {
|
||||
switch (t2) {
|
||||
case T.A -> System.out.println(1);
|
||||
case T.B -> System.out.println(2);
|
||||
case T.C -> System.out.println(3);
|
||||
}
|
||||
}
|
||||
|
||||
public void test1(IT t2) {
|
||||
switch (<error descr="'switch' statement does not cover all possible input values">t2</error>) {
|
||||
case T.A -> System.out.println(1);
|
||||
case T.B -> System.out.println(2);
|
||||
case T.C -> System.out.println(3);
|
||||
}
|
||||
}
|
||||
|
||||
public void test2(IT t2) {
|
||||
switch (t2) {
|
||||
case T.A -> System.out.println("1");
|
||||
case <error descr="Cannot resolve symbol 'B'">B</error> -> System.out.println("2");
|
||||
case T.C -> System.out.println("3");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,10 +70,15 @@ public class LightPatternsForSwitchHighlightingTest extends LightJavaCodeInsight
|
||||
public void testSwitchExhaustivenessForDirectClassesIn21Java() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_21, this::doTest);
|
||||
}
|
||||
|
||||
public void testSwitchExhaustivenessWithConcreteSealedClassesIn21Java() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_21, this::doTest);
|
||||
}
|
||||
|
||||
public void testSwitchExhaustivenessForEnumsWithSealedClassesIn21Java() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_21, this::doTest);
|
||||
}
|
||||
|
||||
public void testSwitchExhaustivenessIn20Java() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_20_PREVIEW, this::doTest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user