public class PrimitiveSwitchValueDominationTightened { static void main() { } public void testNullDominated() { Integer integer = 1; switch (integer) { case Integer i -> { } case null -> { } } } interface A1{} interface A2{} public static void testInterface() { A1 a1 = new A1() { }; switch (a1) { case A1 a-> System.out.println(1); case A2 a-> System.out.println(1); //error } } public static void testWrapper() { int a = 1; switch (a) { case Number number -> System.out.println(2); case 1 -> System.out.println(1); //error } } public static void testWrapperInt() { int a = 1; switch (a) { case Integer number -> System.out.println(2); case 1 -> System.out.println(1); //error } } public static void testWrapperChar() { int a = 1; switch (a) { case char number -> System.out.println(2); case 1 -> System.out.println(1); //error default -> System.out.println(""); } } public static void testWrapperObject() { Object a = 1; switch (a) { case 1 -> System.out.println(1); //error case char number -> System.out.println(2); default -> System.out.println(""); } } public static void testString() { String a = "abc"; switch (a) { case CharSequence string -> System.out.println(2); case "abc" -> System.out.println(2); //error } } public static void testEnum() { enum ABC {A, B, ABC,} Object a = ABC.A; switch (a) { case ABC aa -> System.out.println(2); case ABC.A -> System.out.println(2); //error } } public static void testByte() { int a = 1; switch (a) { case char c -> System.out.println(2); case (byte) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Byte.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Byte.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (byte) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Byte.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Byte.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case (byte) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Byte.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Byte.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case (byte) 0 -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Byte.MAX_VALUE -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Byte.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Byte.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case (byte) 0 -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Byte.MAX_VALUE -> System.out.println(2); //error } switch (a) { case float c -> System.out.println(2); case (byte) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Byte.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Byte.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case (byte) 0 -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Byte.MAX_VALUE -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Byte.MIN_VALUE -> System.out.println(2); //error } } public static void testChar() { int a = 1; switch (a) { case char c -> System.out.println(2); case (char) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Character.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Character.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (char) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Character.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Character.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (char)(128) -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (char)(127) -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case (char) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Character.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Character.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case (char) 0 -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Character.MAX_VALUE -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Character.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Character.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case (char) 0 -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Character.MAX_VALUE -> System.out.println(2); //error } switch (a) { case float c -> System.out.println(2); case (char) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Character.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Character.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case (char) 0 -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Character.MAX_VALUE -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Character.MIN_VALUE -> System.out.println(2); //error } int a2 = 1; switch (a2) { case Integer c -> System.out.println(2); case Character.MIN_VALUE -> System.out.println(2); //error } } public static void testShort() { int a = 1; switch (a) { case char c -> System.out.println(2); case (short) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Short.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Short.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (short) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Short.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Short.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (short)(128) -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (short)(127) -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case (short) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Short.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Short.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case (short) 0 -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Short.MAX_VALUE -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Short.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Short.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case (short) 0 -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Short.MAX_VALUE -> System.out.println(2); //error } switch (a) { case float c -> System.out.println(2); case (short) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Short.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Short.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case (short) 0 -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Short.MAX_VALUE -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Short.MIN_VALUE -> System.out.println(2); //error } int a2 = 1; switch (a2) { case Integer c -> System.out.println(2); case Short.MIN_VALUE -> System.out.println(2); //error from javac but it is not a pattern! } } public static void testInt() { int a = 1; switch (a) { case char c -> System.out.println(2); case (int) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Integer.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (int) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Integer.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (int)(128) -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (int)(127) -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case (int) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Integer.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case (int) 0 -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Integer.MAX_VALUE -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case (int) 0 -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Integer.MAX_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); //error } switch (a) { case float c -> System.out.println(2); case (int) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Integer.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case (int) 0 -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Integer.MAX_VALUE -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); //error } int a2 = 1; switch (a2) { case Integer c -> System.out.println(2); case Integer.MIN_VALUE -> System.out.println(2); } } public static void testLong() { long a = 1; switch (a) { case char c -> System.out.println(2); case (long) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Long.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Long.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Long.MAX_VALUE - (long) 9.22e18 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x001fffffffffffffL -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (long) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Long.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Long.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Long.MAX_VALUE - (long) 9.22e18 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x001fffffffffffffL -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (long)(128) -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (long)(127) -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case (long) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Long.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Long.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Long.MAX_VALUE - (long) 9.22e18 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x001fffffffffffffL -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case (long) 0 -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Long.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Long.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x001fffffffffffffL -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Long.MIN_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case (long) 0 -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Long.MAX_VALUE -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Long.MAX_VALUE - (long) 9.22e18 -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case 0x001fffffffffffffL -> System.out.println(2); //error } switch (a) { case float c -> System.out.println(2); case (long) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Long.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Long.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Long.MAX_VALUE - (long) 9.22e18 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x001fffffffffffffL -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case (long) 0 -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Long.MAX_VALUE -> System.out.println(2); default -> System.out.println(1); } switch (a) { case double c -> System.out.println(2); case Long.MIN_VALUE -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Long.MAX_VALUE - (long) 9.22e18 -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case 0x001fffffffffffffL -> System.out.println(2); //error } } public static void testFloat() { float a = 1; switch (a) { case char c -> System.out.println(2); case (float) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Float.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Float.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Float.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case +0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case -0.0f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Float.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Float.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x1p63f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x1p5f -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x1p62f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x1p31f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (float) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Float.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Float.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Float.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case +0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case -0.0f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Float.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Float.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x1p63f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x1p5f -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x1p62f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x1p31f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case (float) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Float.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Float.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Float.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case +0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case -0.0f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Float.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Float.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x1p63f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x1p5f -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x1p62f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x1p31f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case (float) 0 -> System.out.println(2); //error } switch (a) { case int c -> System.out.println(2); case Float.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Float.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Float.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case +0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case -0.0f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Float.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Float.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x1p63f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x1p5f -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x1p62f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x1p31f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Float.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Float.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Float.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case +0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case -0.0f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Float.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0x1p63f -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0x1p5f -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0x1p62f -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0x1p31f -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case (float) 0 -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Float.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case (float) 0 -> System.out.println(2); //error } switch (a) { case float c -> System.out.println(2); case Float.NaN -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Float.NEGATIVE_INFINITY -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Float.POSITIVE_INFINITY -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case +0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case -0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Float.MAX_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Float.MIN_VALUE -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x1p63f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x1p5f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x1p62f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x1p31f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case (float) 0 -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Float.NaN -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case Float.NEGATIVE_INFINITY -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case Float.POSITIVE_INFINITY -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case +0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case -0.0f -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case double c -> System.out.println(2); case Float.MAX_VALUE -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case Float.MIN_VALUE -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case 0x1p63f -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case 0x1p5f -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case 0x1p62f -> System.out.println(2); //error } switch (a) { case double c -> System.out.println(2); case 0x1p31f -> System.out.println(2); //error } } public static void testDouble() { double a = 1; switch (a) { case char c -> System.out.println(2); case (double) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Double.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Double.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Double.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case +0.0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case -0.0 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Double.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case Double.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x1p63 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x1p5 -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x1p62 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case char c -> System.out.println(2); case 0x1p31 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case (double) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Double.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Double.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Double.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case +0.0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case -0.0 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Double.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case Double.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x1p63 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x1p5 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x1p62 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case byte c -> System.out.println(2); case 0x1p31 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case (double) 0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Double.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Double.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Double.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case +0.0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case -0.0 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Double.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case Double.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x1p63 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x1p5 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x1p62 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case short c -> System.out.println(2); case 0x1p31 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case (double) 0 -> System.out.println(2); } switch (a) { case int c -> System.out.println(2); case Double.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Double.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Double.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case +0.0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case -0.0 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Double.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case Double.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x1p63 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x1p5 -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x1p62 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case int c -> System.out.println(2); case 0x1p31 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0d -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Double.NaN -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Double.NEGATIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Double.POSITIVE_INFINITY -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case +0.0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case -0.0 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case Double.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0x1p63 -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0x1p5 -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0x1p62 -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case 0x1p31 -> System.out.println(2);//error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case long c -> System.out.println(2); case (double) 0 -> System.out.println(2); //error } switch (a) { case long c -> System.out.println(2); case Double.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case (double) 0 -> System.out.println(2); //error } switch (a) { case float c -> System.out.println(2); case Double.NaN -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Double.NEGATIVE_INFINITY -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Double.POSITIVE_INFINITY -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case +0.0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case -0.0 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Double.MAX_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case Double.MIN_VALUE -> System.out.println(2); default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x1p63 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x1p5 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x1p62 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } switch (a) { case float c -> System.out.println(2); case 0x1p31 -> System.out.println(2); //error default -> throw new IllegalStateException("Unexpected value: " + a); } } }