Erasure type inference issue in Java

Recently I was working with the following code:

I was compiling it with

on Windows 10 x64. It wasn’t working because of the following:

You can try reproducing the issue at, it throws the error at the moment.

I was almost sure that it was a bug in javac, especially that the code was working fine in Java 12 as indicated by Ideone.

Fortunately, with some help from community I was finally pointed out in the right direction. It is a bug and Oracle knows about that. You can see details at Oracle page.

Takeaway is: most of the time the problem is on the user side, compiler/platform/OS/library/CPU works well. However, sometimes one just hits a bug.