/
githubmirror
/
panama-vector
Обзор
Документация
Войти
/
githubmirror
/
panama-vector
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/langtools/tools/javac/patterns/PrimitivePatternsSwitchConstants.java
71 строка
2 KB
Jan Lahoda
8367530: The exhaustiveness errors could be improved
04 фев 2026, 14:03
04 фев 2026, 14:03
84e8787
Код
Авторство
О чём код?
/* * @test /nodynamiccopyright/ * @summary Retain exhaustiveness properties of switches with a constant selector * @enablePreview * @compile/fail/ref=PrimitivePatternsSwitchConstants.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDexhaustivityMaxBaseChecks=0 PrimitivePatternsSwitchConstants.java */ public class PrimitivePatternsSwitchConstants { void testConstExpressions() { switch (42) { // error: not exhaustive case byte _ : } switch (42l) { // error: not exhaustive case byte _ : } switch (123456) { // error: not exhaustive case byte _ : } switch (16_777_216) { // error: not exhaustive case float _ : } switch (16_777_217) { // error: not exhaustive case float _ : } switch (42d) { // error: not exhaustive case float _ : } switch (1) { // OK case long _ : } final int i = 42; switch (i) { // OK case long _ : } switch (1) { // error: non-exhaustive case Long _ : // error: widening primitive conversion and boxing is not supported } switch (42) { case byte bb -> {} case int ii -> {} // OK }; switch (42) { case 42 -> {} case int ii -> {} // OK }; switch (42) { case (byte) 42 -> {} case int ii -> {} // OK }; switch (42) { case 42 -> {} default -> {} // OK }; switch (42) { default -> {} // OK case 42 -> {} }; } }