Files
codeql/java/ql/test/library-tests/pattern-switch/dfg/GuardTest.java
2023-11-30 11:24:00 +00:00

31 lines
415 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;
}
}
}