import java.lang.Integer; import java.lang.Double; import java.lang.Number; public record R(Number n) {} public class SwitchOverload { Number f(Double d) { return d * 2; } Number f(Integer i) { return i * 5; } public m(r, x) { x = x + x; return switch(r) { case R(o) -> { x = x + x; yield f(o); } }; } }