import java.util.function.*; class MyTest { T foo(T t) { return t; } T foo(Supplier t) { return t.get(); } T foo(IntSupplier t) { return null; } static K bar() { return null; } void m(int i) { String s = foo(switch (i) {default -> "str";}); String s1 = foo(switch (i) {case 1 -> new Object(); default -> "str";}); String s2 = foo(() -> switch (i) { default -> "str"; }); String s3 = foo(() -> switch (i) {default -> bar();}); String s4 = foo(() -> switch (i) {default -> { yield bar();}}); String s5 = foo(() -> switch (i) {default -> { yield 1;}}); String s6 = switch (i) { case 1 -> 2; default -> { yield 1; } }; Supplier stringSupplier = switch (i) { default -> { yield () -> 1; } }; String s7 = switch (i) { case 1: { yield 1; } default: { int i1 = switch (0) { default -> { yield 1; } }; yield ""; } }; } void switchChain(final int i) { String s = switch (i) { default -> switch (0) { default -> { yield 1; } }; }; String s1 = switch (i) { default -> { yield switch (0) { default -> { yield 1; } }; } }; String s2 = switch (i) { default: { yield switch (0) { default -> { yield 1; } }; } }; String s3 = switch (0) { default: { yield switch (1) { case 2: { System.out.println(); int inside_switch = switch (8) { default: yield 1; }; } case 1: if (i > 3) yield 3; case 0: try { yield 42; } finally { //do nothing } default: yield 1; }; } }; Runnable r = () -> switch(0) { default -> throw new IllegalArgumentException(); }; var rv = switch (0) { case 0 -> 42; default -> System.out.println(42); }; var rv1 = switch (0) { default -> null; }; } static void test(boolean b, int i) { Class c = (b ? switch (i) { case 1 -> true; default -> 0; } : 1).getClass(); System.out.println(c.getCanonicalName()); } interface I { void m(); } interface I1 extends I {} interface I2 extends I {} static void n(I1 i1, I2 i2, int s) { var i_ = switch (s) { case 1 -> i1; case 2 -> null; default -> i2; }; if (i_ != null) { i_.m(); } var i__ = switch (s) { case 2 -> null; case 1 -> i1; default -> i2; }; if (i__ != null) { i__.m(); } } }