[java-highlighting] IDEA-324327 Constant associated with switch block must be used with primitives or String

GitOrigin-RevId: 864329b3d6cbefdf9c72358064b1e14f2fc4a1e3
This commit is contained in:
Mikhail Pyltsin
2023-07-04 21:00:49 +02:00
committed by intellij-monorepo-bot
parent 014b89199b
commit 0254c50753
4 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
public class ConstantAssignment {
void dd(Double i) {
switch (i) {
case <error descr="Unexpected type. Found: 'double', required: 'char, byte, short, int, Character, Byte, Short, Integer, String'">1.0</error> -> System.out.println(1);
default -> throw new IllegalStateException("Unexpected value: " + i);
}
}
void dd2(Long i) {
switch (i) {
case <error descr="Unexpected type. Found: 'long', required: 'char, byte, short, int, Character, Byte, Short, Integer, String'">1L</error>:
System.out.println(1);
default:
throw new IllegalStateException("Unexpected value: " + i);
}
}
}