<div dir="ltr">I've run into either a corner case in type resolution or a compiler bug and I'm not sure which.<br><br>In an expression context, if a static method is referenced from a generic class then it won't properly target overloads that require primitive wrapper unboxing.<br><br><font face="monospace">package org.example;<br><br>import java.time.Month;<br>import java.util.function.Supplier;<br><br><br>interface A {<br>    static int f() {<br>        return 1;<br>    }<br>}<br><br>interface B<T> {<br>    static int f() {<br>        return 2;<br>    }<br>}<br><br>final class C {<br>    static int f() {<br>        return 3;<br>    }<br>}<br><br>final class D<T> {<br>    static int f() {<br>        return 4;<br>    }<br>}<br><br><br>public class Main {<br>    static void h(Month b) {}<br>    static void h(int b) {}<br><br>    static <T> T g(Supplier<? extends T> d) {<br>        return d.get();<br>    }<br><br><br>    public static void main(String[] args) {<br>        // Compiles<br>        h(<br>                g(A::f)<br>        );<br><br>        // Doesn't compile<br>        h(<br>                g(B::f)<br>        );<br><br>        // Compiles<br>        var r1 = g(B::f);<br>        h(r1);<br>        <br>        // Compiles<br>        h(<br>                g(C::f)<br>        );<br><br>        // Doesn't compile<br>        h(<br>                g(D::f)<br>        );<br>        <br>        // Compiles<br>        var r2 = g(D::f);<br>        h(r2);<br>    }<br>}</font><br></div>