Skip to content

Commit

Permalink
Small change in instanceofs integration to account for the slightly…
Browse files Browse the repository at this point in the history
… different boxing semantics under javac.

In conditionals that need boxing, e.g.

```
int m, n;
...
Object o = b ? m : n;

```

the javac frontend expresses the conditional as returning `Object` expressing that the boxing occurs as if written:

```
int m, n;
...
Object o = b ? (Object) m : (Object) n;

```

PiperOrigin-RevId: 702100822
  • Loading branch information
rluble authored and copybara-github committed Dec 2, 2024
1 parent bfdb596 commit b72178b
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ default void dummy(int i) {}

private static class Implementor implements ChildInterface, GenericInterface<String> {}

@SuppressWarnings("cast")
private static void testInstanceOf_array() {
// TODO(b/184675805): Enable for Wasm when array metadata is fully implemented.
if (isWasm()) {
Expand Down Expand Up @@ -379,7 +378,7 @@ private static void testInstanceOf_patternVariable() {
String hello = "hello";
Object o = hello;
assertTrue(o instanceof String s && s.length() == hello.length());
assertEquals(hello.length(), o instanceof String s ? s.length() : 0);
assertTrue(hello.length() == (o instanceof String s ? s.length() : 0));

String bye = "bye";
o = bye;
Expand Down

0 comments on commit b72178b

Please sign in to comment.