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

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Feb 20 04:10:01 PST 2012


Hi,
target-typing in cast context is still an open issue in both the 
compiler and the language spec.

Maurizio

On 20/02/12 10:03, bitter_fox wrote:
> 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