Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsWithPrimitives/BoxedFloatLiterals.java
T
Mikhail Pyltsin b8bcd55bae [java] IDEA-390261 Support JEP 532: Primitive Types in Patterns, instanceof, and switch (Fifth Preview)
- more tests

(cherry picked from commit 0a0af605b7a6a79427eb88d1f92af728d500932a)

GitOrigin-RevId: f9077865cc33ce8c8fbea5394ee1f882df675a11
2026-07-23 10:59:41 +00:00

33 lines
875 B
Java

package dfa;
public class BoxedFloatLiterals {
int examineFloat(Float f) {
final Float PInf = Float.POSITIVE_INFINITY;
final Float NInf = Float.NEGATIVE_INFINITY;
final Float NaN = Float.NaN;
return switch (f) {
case <error descr="Constant expression required">NInf</error> -> -100;
case -0.0f -> -1;
case 0.0f -> +1;
case <error descr="Constant expression required">PInf</error> -> +100;
case <error descr="Constant expression required">NaN</error> -> 0;
default -> 42;
};
}
int examineFloat2(Float f) {
final float PInf = Float.POSITIVE_INFINITY;
final float NInf = Float.NEGATIVE_INFINITY;
final float NaN = Float.NaN;
return switch (f) {
case NInf -> -100;
case -0.0f -> -1;
case 0.0f -> +1;
case PInf -> +100;
case NaN -> 0;
default -> 42;
};
}
}