Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/SwitchWithPrimitivesNotAllowed.java
Mikhail Pyltsin 45160db0df [java-highlighting] IDEA-352588 Support JEP 455: highlighting for switch with primitives
GitOrigin-RevId: 06636352b202037ec3400b2f9763e101d8ed6042
2024-04-29 21:17:42 +00:00

79 lines
2.1 KiB
Java

package dfa;
public class SwitchWithPrimitivesNotAllowed {
public static void main(String[] args) {
testPrimitives();
testWrappers();
}
private static void testWrappers() {
Boolean b = true;
switch (b) {
default -> System.out.println("1");
}
Integer i = 1;
switch (i) {
default -> System.out.println("1");
}
Short s = 1;
switch (s) {
default -> System.out.println("1");
}
Byte by = 1;
switch (by) {
default -> System.out.println("1");
}
Character ch = '1';
switch (ch) {
default -> System.out.println("1");
}
Long l = 1L;
switch (l) {
default -> System.out.println("1");
}
Double d = 1.0;
switch (d) {
default -> System.out.println("1");
}
Float f = 1.0F;
switch (f) {
default -> System.out.println("1");
}
}
private static void testPrimitives() {
boolean b = true;
switch (<error descr="Selector type of 'boolean' is not supported">b</error>) {//error
default -> System.out.println("1");
}
int i = 1;
switch (i) {
default -> System.out.println("1");
}
short s = 1;
switch (s) {
default -> System.out.println("1");
}
byte by = 1;
switch (by) {
default -> System.out.println("1");
}
char ch = '1';
switch (ch) {
default -> System.out.println("1");
}
long l = 1L;
switch (<error descr="Selector type of 'long' is not supported">l</error>) { //error
default -> System.out.println("1");
}
double d = 1.0;
switch (<error descr="Selector type of 'double' is not supported">d</error>) {//error
default -> System.out.println("1");
}
float f = 1.0F;
switch (<error descr="Selector type of 'float' is not supported">f</error>) {//error
default -> System.out.println("1");
}
}
}