package dfa; public class SwitchPrimitivePatternDominated { public static void main(String[] args) { testBoolean(); testChar(); testByte(); testShort(); testInt(); testLong(); testFloat(); testDouble(); } private static void testDouble() { Object o = 1; switch (o) { case byte a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case int a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case float a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case double a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case double a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case Byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Byte a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case Short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Short a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case Character a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Character a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Integer a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case Integer a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Long a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case Long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Float a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case Float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Double a -> System.out.println("1"); case double a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case Double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Number a -> System.out.println("1"); case double a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case Number a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Object a -> System.out.println("1"); case double a -> System.out.println("1");//error } switch (o) { case double a -> System.out.println("1"); case Object a -> System.out.println("1"); } } private static void testFloat() { Object o = 1; switch (o) { case byte a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case float a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case float a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case float a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case Byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Byte a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case Short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Short a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case Character a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Character a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Integer a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case Integer a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Long a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case Long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Float a -> System.out.println("1"); case float a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case Float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Double a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case Double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Number a -> System.out.println("1"); case float a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case Number a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Object a -> System.out.println("1"); case float a -> System.out.println("1");//error } switch (o) { case float a -> System.out.println("1"); case Object a -> System.out.println("1"); } } private static void testLong() { Object o = 1; switch (o) { case byte a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case int a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case long a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case long a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case Byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Byte a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case Short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Short a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case Character a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Character a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Integer a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case Integer a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Long a -> System.out.println("1"); case long a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case Long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Float a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case Float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Double a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case Double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Number a -> System.out.println("1"); case long a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case Number a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Object a -> System.out.println("1"); case long a -> System.out.println("1");//error } switch (o) { case long a -> System.out.println("1"); case Object a -> System.out.println("1"); } } private static void testInt() { Object o = 1; switch (o) { case byte a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case int a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case int a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case int a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case int a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case Byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Byte a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case Short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Short a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case Character a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Character a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Integer a -> System.out.println("1"); case int a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case Integer a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Long a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case Long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Float a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case Float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Double a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case Double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Number a -> System.out.println("1"); case int a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case Number a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Object a -> System.out.println("1"); case int a -> System.out.println("1");//error } switch (o) { case int a -> System.out.println("1"); case Object a -> System.out.println("1"); } } private static void testShort() { Object o = 1; switch (o) { case byte a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case Byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Byte a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case Short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Short a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case Character a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Character a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Integer a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case Integer a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Long a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case Long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Float a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case Float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Double a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case Double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Number a -> System.out.println("1"); case short a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case Number a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Object a -> System.out.println("1"); case short a -> System.out.println("1");//error } switch (o) { case short a -> System.out.println("1"); case Object a -> System.out.println("1"); } } private static void testByte() { Object o = 1; switch (o) { case byte a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case Byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Byte a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case Short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Short a -> System.out.println("1"); case byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case Character a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Character a -> System.out.println("1"); case byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Integer a -> System.out.println("1"); case byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case Integer a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Long a -> System.out.println("1"); case byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case Long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Float a -> System.out.println("1"); case byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case Float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Double a -> System.out.println("1"); case byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case Double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Number a -> System.out.println("1"); case byte a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case Number a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Object a -> System.out.println("1"); case byte a -> System.out.println("1");//error } switch (o) { case byte a -> System.out.println("1"); case Object a -> System.out.println("1"); } } private static void testChar() { Object o = 1; switch (o) { case char a -> System.out.println("1"); case byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case byte a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case short a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case int a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case int a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case long a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case float a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case double a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case Byte a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Byte a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case Short a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Short a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case Character a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Character a -> System.out.println("1"); case char a -> System.out.println("1");//error default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Integer a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case Integer a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Long a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case Long a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Float a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case Float a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Double a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case Double a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Number a -> System.out.println("1"); case char a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case char a -> System.out.println("1"); case Number a -> System.out.println("1"); default -> throw new IllegalStateException("Unexpected value: " + o); } switch (o) { case Object a -> System.out.println("1"); case char a -> System.out.println("1");//error } switch (o) { case char a -> System.out.println("1"); case Object a -> System.out.println("1"); } } private static void testBoolean() { Object o = 1; switch (o) { case boolean b -> System.out.println("2"); case long b -> System.out.println("2"); default -> System.out.println("1"); } switch (o) { case long b -> System.out.println("2"); case boolean b -> System.out.println("2"); default -> System.out.println("1"); } switch (o) { case boolean b -> System.out.println("2"); case Boolean b -> System.out.println("2"); default -> System.out.println("1"); } switch (o) { case boolean b -> System.out.println("2"); case Object b -> System.out.println("2"); } switch (o) { case Boolean b -> System.out.println("2"); case boolean b -> System.out.println("2");//error default -> System.out.println("1"); } switch (o) { case Object b -> System.out.println("2"); case boolean b -> System.out.println("2");//error } } }