class M { interface Map { Y get(X x); } Map m; Y y; public M(Map m, Y y) { this.m = m; this.y = y; } public static M makeM(MY y) { return new M(null, y); } Y get(X x) { Y res = m.get(x); return res == null ? y : res; } public static void g() { String a = f(M.makeM("a"), "k"); } public static A f(M a, A ka) { return a.get(ka); } }