Slightly incorrect diagnostic

Mark Mahieu mark at twistedbanana.demon.co.uk
Mon Jul 7 11:58:37 PDT 2008


Ah, yes I see - thanks for the explanation!

I'd somehow got it into my head that the restricted interface types  
also (re)declare their invoke method, rather than just inherit it.


On 7 Jul 2008, at 09:06, Neal Gafter wrote:

> 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/42b5a993/attachment.html 


More information about the closures-dev mailing list