Skip to content

Commit 47e3d7d

Browse files
committed
Cast back to Object in advance of returning, to ensure the test doesn't mask a shortcoming of type pruning by pruning at the return site
1 parent f0144d6 commit 47e3d7d

File tree

1 file changed

+4
-4
lines changed
  • java/ql/test/library-tests/flow-through-binding

1 file changed

+4
-4
lines changed

java/ql/test/library-tests/flow-through-binding/Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ public class Test {
33
public static Object testFlowThroughSwitchStmt(String s, Integer i, boolean unknown) {
44
Object o = unknown ? s : i;
55
switch (o) {
6-
case Integer i2 -> { return i2; }
6+
case Integer i2 -> { return (Object)i2; }
77
default -> { return null; }
88
}
99
}
1010

1111
public static Object testFlowThroughSwitchExpr(String s, Integer i, boolean unknown) {
1212
Object o = unknown ? s : i;
13-
Integer toRet = switch (o) {
14-
case Integer i2 -> i2;
13+
Object toRet = switch (o) {
14+
case Integer i2 -> (Object)i2;
1515
default -> null;
1616
};
1717
return toRet;
@@ -20,7 +20,7 @@ public static Object testFlowThroughSwitchExpr(String s, Integer i, boolean unkn
2020
public static Object testFlowThroughBindingInstanceOf(String s, Integer i, boolean unknown) {
2121
Object o = unknown ? s : i;
2222
if (o instanceof Integer i2)
23-
return i2;
23+
return (Object)i2;
2424
else
2525
return null;
2626
}

0 commit comments

Comments
 (0)