Is target-typing for conditional expressions in cast context supported?

bitter_fox bitterfoxc at gmail.com
Mon Feb 20 02:03:28 PST 2012


Hi,
when I compile this program, the compiler which is the newest binary
snapshot says it is illegal.

class Main
{
    interface SAM
    {
        void invoke();
    }

    public static void main(String[] args)
    {
        Object obj = (SAM)(true ? () -> {} : () -> {}); // Illegal
    }
}

I know that there is a compiler option to enable target-typing in method
invocation context:
    -XDcomplexinference
But it does not work to this situation.
Is there another compiler option to enable target-typing in cast context?

Regards,
bitter_fox


More information about the lambda-dev mailing list