Slightly incorrect diagnostic

Neal Gafter neal at gafter.com
Mon Jul 7 01:06:05 PDT 2008


After analysis, it appears that the compiler's diagnostic, while admittedly
a bit puzzling, is technically correct.  The type of this closure literal is
the interface type *{ ==> void }*, which inherits its *invoke* method from *{
==> void }.*  Therefore the compiler is technically correct in reporting
which method it is unable to apply to the argument "1".

On the other hand, we should do better.

On Thu, May 15, 2008 at 2:05 PM, Mark Mahieu <mark at twistedbanana.demon.co.uk>
wrote:

> I've found another example where the compiler gives a slightly misleading
> compilation error:
>
>
> public class WrongType {
>
>    public static void main(String[] args) {
>        {=>}.invoke(1);
>    }
> }
>
>
> The message refers to an unrestricted type, yet I only have a restricted
> closure:
>
> WrongType.java:4: invoke() in { ==> void} cannot be applied to (int)
>                {=>}.invoke(1);
>                    ^
> 1 error
>
>
>
> Regards,
>
> Mark
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20080707/aeb2751c/attachment.html 


More information about the closures-dev mailing list