Files
codeql/java/ql/test/library-tests/pattern-switch/dfg/GuardTest.java

30 lines
414 B
Java

public class GuardTest {
public static void sink(String s) { }
public static boolean isSafe(String s) { return s.length() < 10; }
public static void test(Object o) {
switch (o) {
case String s:
sink(s);
break;
default:
break;
}
switch (o) {
case String s when isSafe(s):
sink(s);
break;
default:
break;
}
}
}