Casting to a closure
Neal Gafter
neal at gafter.com
Mon May 19 08:44:14 PDT 2008
Yes, function types are not reified, so the warning is required. That's a
consequence of their specification in terms of generic interface types. One
thing I had considered doing is making function type reified when there are
no exceptions and only primitive arguments and returns, which would make
this particular case (and others where people have noticed this problem,
such as with {double=>double}) compile without a warning.
On Mon, May 19, 2008 at 1:56 AM, Zdenek Tronicek <tronicek at fel.cvut.cz>
wrote:
> Casting to a closure generates a warning:
>
> Object o = { => Math.random() };
> { => double } p = ({ => double }) o;
>
> TypeCasting.java:13: warning: [unchecked] unchecked cast
> found : java.lang.Object
> required: { => double}
> { => double } p = ({ => double }) o;
> ^
> 1 warning
>
> Z.
> --
> Zdenek Tronicek
> Department of Computer Science and Engineering
> Prague tel: +420 2 2435 7410
> http://cs.felk.cvut.cz/~tronicek <http://cs.felk.cvut.cz/%7Etronicek>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20080519/45adf9a7/attachment.html
More information about the closures-dev
mailing list