Skip to content

Commit

Permalink
InstanceOfPatternMatch: introduce failing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie committed Mar 1, 2024
1 parent e9f5fc5 commit 735b18b
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,5 +791,32 @@ String test(Object o) {
)
);
}

@Test
void multipleCastsInDifferent() {
rewriteRun(
//language=java
java(
"""
import java.util.Comparator;
public class A {
Comparator<Object> comparator() {
return (a, b) ->
(a instanceof String) && (b instanceof String) ? ((String) a).compareTo((String) b) : 0;
}
}
""",
"""
import java.util.Comparator;
public class A {
Comparator<Object> comparator() {
return (a, b) ->
(a instanceof String s) && (b instanceof String s) ? s.compareTo(s) : 0;
}
}
"""
)
);
}
}
}

0 comments on commit 735b18b

Please sign in to comment.