1 /** 2 * @test /nodynamiccopyright/ 3 * @bug 8206986 4 * @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source 12 BooleanNumericNonNumeric.java 5 */ 6 7 public class BooleanNumericNonNumeric { 8 9 private void test(boolean b, int i) { 10 int r1 = 1 + (b ? switch (i) { //boolean, error 11 default -> true; 12 } : false); 13 int r2 = 1 + (b ? switch (i) { //int, ok 14 default -> 0; 15 } : 1); 16 (b ? switch (i) { //int, error 17 default -> 0; 18 } : 1).toString(); 19 (b ? switch (i) { //"object", ok 20 case 0 -> true; 21 default -> 0; 22 } : 1).toString(); 23 } 24 25 }