import java.util.function.Predicate; class RedundantCast { private static void foo(final int matchType) { Object o = switch (matchType) { default -> (Predicate) target -> target == null; }; Predicate o1 = switch (matchType) { default -> (Predicate) target -> target == null; }; Predicate o2 = switch (matchType) { default: yield (Predicate) target -> target == null; }; } }